Summary of TypeScript knowledge points

insert image description here
For developers with experience in forced-type languages, most of them have a feeling of "heart like a thorn, like a thorn in the throat" when they first come into contact with JavaScript .

From the initial favor --- open and tolerant , to the later disgust -- bohemian

TypeScript is like a ray of sunshine in the darkness, saving these souls who yearn for freedom.


1. JavaScript OR TypeScript ?

For friends who are new to the front-end, when TypeScript is highly recommended around them , an idea naturally arises: Can you learn TypeScript directly?

You can't learn TypeScript without learning JavaScript! TypeScript shares the syntax and runtime behavior of JavaScript . So, any knowledge of JavaScript can help you learn TypeScript.

static checking

Detecting bugs in the code without running it is called static checking

static type checking

Determine what is wrong and what is not based on the kind of value being manipulated, which is called static type checking

static type checker

TypeScript checks programs for errors with value-based types before executing them. It is a static type checker

TypeScript's type checker is designed to allow correct programs through while still catching as many common errors as possible.

The relationship between JS and TS

TypeScript has an unusual relationship with JavaScript. TypeScript provides all the functionality of JavaScript and adds a layer on top of it: TypeScript's type system . That's what it's called: TypeScript is a typed superset of JavaScript .

TypeScript never changes the runtime behavior of JavaScript code. It is the basic promise of TypeScript to maintain the same runtime behavior as JavaScript. TypeScript's compiler has done the work of checking the code, and it will erase the type to generate the final "compiled" code. (JS code);

TypeScript is JavaScript
's runtime with a compile-time type checker.

The main benefit of TypeScript is that it checks for unexpected behavior in your code, reducing the chances of bugs .


For more content, please see the next article TypeScript is a strongly typed, statically typed JavaScript

Guess you like

Origin blog.csdn.net/wangcheeng/article/details/128168784