TypeScript小记

  1. JavaScript is an interpreted language, there is no compilation stage, so it is dynamic type (dynamic type means that type checking is performed only at runtime, and type errors in this language often lead to runtime errors.). TypeScript needs to be compiled into JavaScript before running, and type checking is performed at the compilation stage, so TypeScript is a static type (static typing means that the type of each variable can be determined at the compilation stage. Type errors in this language often lead to Grammatical errors.).

  2. The type system is classified according to "whether implicit type conversion is allowed" and can be divided into strong types and weak types. TypeScript is fully compatible with JavaScript, it does not modify the characteristics of JavaScript runtime, so they are all weak types.

  3. In TypeScript, we use: to specify the type of the variable, with or without spaces before and after:.

  4. Any value (Any) is used to indicate that the assignment is allowed to be of any type.

  5. TypeScript will infer a type when it is not explicitly specified. This is type inference.

  6. TypeScript is used 编译上下文to group files and tell TypeScript which files are valid and which are invalid. In addition to the information carried by the valid file, the compilation context also contains information about the compilation options being used. Such logical grouping defined, a better approach is to use tsconfig.jsonthe file.

  7. There are two declaration spaces in TypeScript: type declaration space (which can be used as type annotations) and variable declaration space.

  8. TypeScript provides global modules and file modules for:引用

  9. When using namespaces in JavaScript

Guess you like

Origin blog.csdn.net/sinat_19550501/article/details/112794741