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

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.

主站蜘蛛池模板: 天长市| 怀宁县| 阿城市| 沂水县| 囊谦县| 关岭| 平武县| 苍山县| 高雄市| 玉溪市| 县级市| 常德市| 肇东市| 丰县| 股票| 开远市| 大安市| 河曲县| 屏山县| 霍邱县| 蒲城县| 冀州市| 广元市| 红桥区| 清丰县| 朝阳县| 博湖县| 三门县| 丽江市| 富裕县| 青神县| 精河县| 晋城| 商城县| 万州区| 沙雅县| 合水县| 屏边| 启东市| 海丰县| 镇坪县|