官术网_书友最值得收藏!

Any

What if we declare a variable with no type annotation and no value? What does TypeScript infer as the type? Let's enter the following code in the TypeScript playground and find out:

let flag;

If we hover our mouse over flag, we see it has been given the any type:

So, the TypeScript compiler gives a variable with no type annotation and no immediately assigned value, the any type. The any type is specific to TypeScript; it doesn't exist in JavaScript. It is a way of opting out of type checking on a particular variable. It is commonly used for dynamic content or values from third-party libraries. However, TypeScript's increasingly powerful type system means that we need to use any less often these days.

主站蜘蛛池模板: 中阳县| 获嘉县| 宽甸| 岐山县| 喜德县| 县级市| 都昌县| 麦盖提县| 太保市| 彭州市| 黄山市| 深圳市| 青铜峡市| 旺苍县| 乌拉特前旗| 朝阳区| 孝感市| 大化| 永定县| 靖远县| 哈巴河县| 孙吴县| 内乡县| 九龙城区| 额济纳旗| 苍山县| 惠水县| 常宁市| 年辖:市辖区| 大宁县| 克什克腾旗| 南城县| 普安县| 西吉县| 靖边县| 壤塘县| 青岛市| 甘南县| 喀喇沁旗| 青铜峡市| 通江县|