In this section, we will learn the TypeScript language. TypeScript name JavaScript very similar to 0611bb9e36bdc2. In fact, the two are indeed related. TypeScript is JavaScript superset, it JavaScript made some specifications and additions.

Introduction to TypeScript

  • TypeScript can be compiled into pure JavaScript , and the compiled JavaScript can be run on any browser.
  • TypeScript can run on any browser, any computer and any operating system, and it is open source.
  • TypeScript extends the JavaScript , so any existing JavaScript program can run in the TypeScript environment.
  • TypeScript originated from a large-scale project developed JavaScript JavaScript language itself, it is difficult to competently and maintain large-scale project development. Therefore, Microsoft has developed TypeScript , which makes it capable of developing large-scale projects.

What is a superset?

Above we said that TypeScript is a JavaScript . So what is a superset?

Superset definition: If a set S2 each element in the collection are S1 , and the collection S1 may contain S2 element is not in, then the set S1 is S2 a superset.

That is to say, JavaScript all functions TypeScript in there, but TypeScript in the function JavaScript would not have, after all, TypeScript extended enhance JavaScript writing experience, such as: static type checking JavaScript no, but depends TypeScript can be very convenient Perform static type checking, so TypeScript is a JavaScript . And TypeScript can eventually generate the standard JavaScript code.

Advantages of TypeScript

  • Typescript support ES6 specification language, ES6 specification states that the future direction of development of client-side scripting language, Typescript syntax scripting language syntax will become the mainstream for some time to the client language.
  • Type detection: When specifying a specific type for a variable Typescript IDE will perform type detection and tell you that there may be errors. This feature can help us reduce the chance of making mistakes in the development phase.
  • Syntax hint: When writing code IDE Typescript IDE will show you the classes, variables, methods and keywords you can use according to your current context. Direct selection, this feature improves development efficiency.
  • It is the development language Angular2 Typescript is helpful for us to learn the Angular2 framework. Angular2 is an open source JavaScript library maintained by Google to assist in the operation of single-page applications.

TypeScript installation

In our installation TypeScript before, we need to ensure that it had installed the Node.js , if not installed please install Node.js .

After installing Node.js , you can start to install TypeScript .

How to install node.js

Node.js download address: https://nodejs.org/en/download/ , after you download it, follow the steps to install it.

After the installation is complete, we can open the terminal on the computer and enter the node -v command in the terminal, as shown below:


If ENTER is pressed, the output interface successful then the version number Node.js has been successfully installed, the installation was successful on FIG v12.16.1 version Node.js .

How to install TypeScript

Node.js comes npm , we can npm install a global TypeScript , enter the following command at the command line:

npm install -g typescript

Press the Enter key to start the installation automatically. After the installation is complete, it will display as shown in the figure below:

Where -g represents the global installation, typescript represents the name of the installed program.

If you want to check whether the installation is successful, you can enter the tsc -v command in the window just now, so you can view TypeScript . The following figure shows the version number as 3.8.3 :

Visual Studio Code

We want to learn TypeScript , first choose an IDE (Integrated Development Environment) that suits you. There are many IDE support TypeScript plug-ins, such as Visual Studio Code , Sublime Text 2 , WebStorm , Eclipse etc. Then I chose Visual Studio Code , so first we need to download and install Visual Studio Code , if you have it on your computer, you don’t need to reinstall it.

Visual Studio Code download address: https://code.visualstudio.com/ .

After downloading, install it according to the prompts. After the installation is complete, open the Visual Studio Code software, and then find the application store:

TypeScript in the search box and click the green install button to install the TypeScript plug-in, as shown in the figure below (the plug-in is already installed, the green button will disappear):

At this point, the preparation work is almost complete. In the next section, we will start to learn Typescript to use 0611bb9e36c6e7.


知否
221 声望177 粉丝

Skrike while the iron is hot.