TypeScript Installation
This article introduces the installation of the TypeScript environment.
We need to use the npm tool to install. If you are not yet familiar with npm, you can refer to ourNPM Usage Introduction。
Installing TypeScript with NPM
If the npm tool is already installed in your local environment, you can use the following command to install.
Use a domestic mirror:
npm config set registry https://registry.npmmirror.com
Install typescript:
npm install -g typescript
After installation, we can use the tsc command to execute TypeScript-related code; the following shows how to check the version:
$ tsc -v
Version 3.2.2
Then we create a new file app.ts with the following code:
var
message
:
string
=
"
Hello World
"
console
.
log
(
message
)
We typically use .ts as the extension for TypeScript code files.
Then run the following command to convert TypeScript into JavaScript code:
tsc app.ts

At this point, an app.js file will be generated in the current directory (the same directory as app.ts), with the following code:
var
message
=
"
Hello World
"
;
console
.
log
(
message
)
;
Use the node command to execute the app.js file:
$ node app.js
Hello World
The process of converting TypeScript to JavaScript is shown in the figure below:

Introduction to VS Code
Many IDEs support TypeScript plugins, such as: VS Code, Sublime Text 2, WebStorm / PHPStorm, Eclipse, etc.
This section mainly introduces VS Code. VS Code is a cross-platform source code editor developed by Microsoft that runs on Mac OS X, Windows, and Linux, aimed at writing modern web and cloud applications.
VS Code tutorial:https://www.runoob.com/vscode/vscode-tutorial.html
In addition, domestic companies Alibaba and ByteDance also have AI IDEs developed based on VS Code:
Installing Visual Studio Code on Windows
1. Download Visual Studio Code。

2. Double-click the VSCodeSetup.exe icon
installation.

3. After installation, opening Visual Studio Code shows an interface similar to the following:

4. We can click the currently edited code file in the left window and select open in command prompt(Open in Terminal); then we can use the lower-right part of the screen to tsc the command to execute TypeScript file code.
Installing Visual Studio Code on Mac OS X
For installing and configuring Visual Studio Code on Mac OS X, see: https://code.visualstudio.com/Docs/editor/setup
Installing Visual Studio Code on Linux
For installing and configuring Visual Studio Code on Linux, see: https://code.visualstudio.com/Docs/editor/setup