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

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.

主站蜘蛛池模板: 正宁县| 水城县| 出国| 峡江县| 湖北省| 株洲县| 弋阳县| 淮北市| 忻州市| 普安县| 固阳县| 喀喇| 冕宁县| 宜城市| 长汀县| 赤峰市| 黔江区| 博客| 临海市| 子长县| 安泽县| 赤峰市| 太康县| 手游| 永城市| 浦江县| 山东| 湖州市| 珠海市| 临沧市| 高淳县| 合川市| 贡嘎县| 军事| 泗阳县| 濮阳县| 泗水县| 平远县| 西畴县| 丰顺县| 合作市|