-
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.).
-
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.
-
In TypeScript, we use: to specify the type of the variable, with or without spaces before and after:.
-
Any value (Any) is used to indicate that the assignment is allowed to be of any type.
-
TypeScript will infer a type when it is not explicitly specified. This is type inference.
-
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 usetsconfig.json
the file. -
There are two declaration spaces in TypeScript: type declaration space (which can be used as type annotations) and variable declaration space.
-
TypeScript provides global modules and file modules for:
引用
-
When using namespaces in JavaScript
TypeScript小记
Guess you like
Origin blog.csdn.net/sinat_19550501/article/details/112794741
Recommended
Ranking