I used to work on iOS and have written swift for a period of time, so it doesn’t really affect me much to switch from JS to TS.

Just some knowledge points more disorderly, did not string up.

First we need to read the typescript documentation

Github has been translating Zhongsp /TypeScript for a long time

In fact, there is a Chinese language option on the official website now, but the translated articles are not too many, and there should be more and more in the future.

So the next step is to connect the dots

The following is a personal point of view, if there is wrong, hope Daniel advice

1. Install typescript globally

Personally I don’t think so. Typescript also comes in versions, and projects install typescript as they go along. There is no need for a global installation.

2. The TSC command

tsc options

Once typescript is installed, TSC is available. TSC can do a lot of things, from TS to JS.

TSC options are actually passed through tsconfig (you can add parameters manually, of course)

3. The tsconfig file

tsconfig

In fact, this is the essence of the configuration of the whole project. Most of the configuration problems encountered can be found in the documentation.

The compilation and static detection of the entire TS project depend on the configuration of the tsconifg file.

4. After the TS project is written, how to generate the D. TS file

Developing libraries or re-packaging well-known libraries is a common requirement, like my first requirement with TS was re-packaging libraries, and the generation of declaration files was a real headache for me.

In fact, add declaration to the tsConfig configuration item. Write outDir as the output path.

5. Why Babel with TS?

Tsconfig target: if you set the target option, you can compile ts into lower versions of js code.

Generally the third party library will do a low version of the compilation, and my own project does not have JS, I personally feel that there is no need.

Because ts compiled it for you.

6. Use ESLint or tsLint

This should not be a problem now, as TSLint has long since been deprecated and esLint is used.

P.S: Can we add a boiling point search function to the gold nuggets search

“By default null and undefined are subtypes of all types. That means you can assign null and undefined to variables of type number.” But the elder brother who released the boiling point said he tried, reported wrong, do not know why.

let aa: number = null;
Copy the code

StrictNullChecks is actually turned off in the documentation