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

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.

主站蜘蛛池模板: 屯昌县| 清水河县| 铅山县| 南宫市| 聂荣县| 文化| 光山县| 太和县| 肥城市| 文昌市| 四会市| 淳安县| 内乡县| 三穗县| 西乡县| 红原县| 长海县| 遂川县| 新竹县| 怀远县| 东辽县| 怀宁县| 平阳县| 阜城县| 金乡县| 黔南| 神农架林区| 中阳县| 高碑店市| 永州市| 疏勒县| 昭觉县| 平罗县| 天峨县| 志丹县| 东莞市| 合阳县| 玉溪市| 灵丘县| 黄梅县| 黑龙江省|