Recently vue 3.0 release, made me realize typescript will occupy an increasingly important position, so I opened the typescript learning journey.
To write your first program hello typescript, of course, necessary to go through the installation process, we are divided into the following steps:
Step a: Global Installation typescript
npm install -g typescript
Step two: the overall installation ts-node
The reason is that it is installed typescript comes tsc command does not run typescript code directly. It is noteworthy that not equal to ts-node Node.js typescript, just encapsulates typescript compilation process, providing the ability to code run directly typescript.
npm install -g ts-node
Step Three: Configure ts-node environment variables
1. To configure the environment variables, we must first know npm global position ts-node installation of
npm config get prefix
2. After the above statements, we can know npm install ts-node global position, the next step is to configure the environment variables:
- Desktop " This Computer " right-click " Properties "
- List on the left window, click on the " Advanced System Settings "
- New window click on the bottom " Environment Variables "
- " System Variables " select " Path ", click " Edit "
- Click on " New ", the path will get 1 copy into it, click Save
- Restart the computer
Step Four: Write the first typescript program
typescript file suffix .ts , file, enter the following:
console.log('Hello Typescript ! ')
Step five: Open the console and enter
ts-node file name .ts // Hello Typescript!
Later formally opened typescript of learning! ! !