A brief introduction to typescript
- Typescript is an open source programming language developed by Microsoft
- Typescript is a superset of JavaScript that follows the latest ES6 and ES5 specifications. Typescript extends JavaScript’s syntax.
- The latest Vue and React also integrate with typescript
- The NodeJS framework NestJS and Midway use typescript syntax.
Second, typescript installation
- 1, CNPM I – g typescript | | NPM I – g typescript | | yarn add – g typescript
- 2. Check whether the installation is successful: TSC-V
- 3, compile: TSC index.ts
Three, compile
- TSC index.ts = TSC index.ts = TSC index.ts I wanted to be lazy, so I thought, how can I compile index.ts automatically on vscode?
- 2. Look at the following steps.
Four, the realization of
- Create tsconfig.json file: TSC –init
- 2. Click terminal to find the configuration task
- 3, enter TSC, select TSC monitor (note, correct path)
- 4. Create an HTML file and import the compiled JS file
- 5. Write code in TS file and compile it into JS file automatically after saving
- 6. After compiling successfully, refresh the HTML page to see the effect
End of the five,
A simple ts file, you can compile perfectly on vscode and see the results. This is great for people who are just learning typescript or who are ready to learn typescript. In this way, while learning with code inspection, master more firmly.