Why add type support to TypeScript? TypeScript Advantages

TypeScript is a superset of JS. It is a combination of TypeScript and JavaScript. It adds a type system to JS based on JS.

Distinguished from the dynamics of programming languages, TypeScript is a statically typed programming language, and JS is a dynamically typed programming language. Static typing does type checking at compile time, and dynamic typing does type checking at execution time. The order of code compilation and code execution itself is 1 compilation 2 execution.

For JS: you need to wait until the code is actually executed to find the error (late).

For TS: errors can be found (early) when the code is compiled (before the code is executed).

Moreover, with development tools such as VSCode, TS can discover errors in the code in advance while writing the code, reducing the time of finding and correcting bugs. Compared with JS, the development experience is more friendly, which increases the happiness of development.

Advantages of TypeScript compared to JS:

1. Discover errors earlier (while writing code), reduce the time of finding and correcting bugs, and improve development efficiency.

2. There are code prompts for the code anywhere in the program, providing a sense of security anytime and anywhere, which enhances the development experience.

3. The powerful type system improves the maintainability of the code and makes it easier to refactor the code.

4. Support the latest ECMAScript syntax, give priority to experience the latest syntax, allowing you to be at the forefront of front-end technology.

5. The TS type inference mechanism does not need to display annotation types everywhere in the code, allowing you to enjoy the advantages while minimizing costs. In addition, Vue 3 source code is rewritten using TS, Angular supports TS by default, and React works perfectly with TS. TypeScript has become the first programming language for large and medium-sized front-end projects.

Guess you like

Origin blog.csdn.net/cz_00001/article/details/132990111