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

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.

主站蜘蛛池模板: 信阳市| 繁峙县| 封丘县| 泌阳县| 中方县| 长泰县| 华池县| 开平市| 内黄县| 铁力市| 施甸县| 和田市| 乡宁县| 庐江县| 车险| 龙南县| 武威市| 德化县| 南木林县| 闽侯县| 巫溪县| 黔东| 北宁市| 清丰县| 新兴县| 瑞丽市| 汾阳市| 台中县| 玉田县| 临城县| 德格县| 赣州市| 澄城县| 图们市| 满城县| 余庆县| 新巴尔虎右旗| 昌图县| 莱阳市| 大荔县| 安泽县|