Use of Typeecript (TS, ts) built-in compilation environment

Posted Jun 7, 20201 min read

Use of Typeecript(TS, ts) built-in compilation environment

1. Install TS package

Npm i -g typescript
Yarn add global typescript

Second, Initialize the project

  1. Create the ts-pratice folder

  2. Enter the ts-pratice folder, enter the command line and enter tsc --init, a global ts configuration file named tsconfig.json will be created in the root directory.

  3. Create a project entry file of index.ts in the root directory

  4. Modify the configuration

    The location of the compiled file


3. Use VScode to open the project folder

  1. Find the menu option of Terminal
  2. Find Run Task in the terminal
  3. Select Monitor typescript in typescript

to sum up

At this time, after writing the typrscript code in the index.ts file, it will be automatically compiled.