Detailed steps to build the TypeScript environment and deploy it to VSCode

Detailed steps to build the TypeScript environment and deploy it to VSCode

Preface: If you want to build TypeScript , you need npm . If you want to have cnpm , you need a node environment. If you have all of them, then read on.

TypeScript environment construction

Step 1: Download Taobao mirror

First check whether you have successfully installed npm

Please add a description of the image

It is not enough to have npm, you also need to download cnpm, the command is as follows (copy and paste directly):

npm install -g cnpm --registry=https://registry.npm.taobao.org

After downloading, it will appear like this.

Please add a description of the image

Step 2: Download TypeScript

In the command window, enter (copy and paste directly):

npm install -g typescript

Download it like this.

Please add a description of the image

Check the version number:

tsc -v

This way TS is completely ready.

Please add a description of the image

Deploy to VSCode

First create a folder tsDemo,

Create a demo.ts file in the tsDemo folder and write the content. .
Next, jump to the tsDemo folder location in the command window.

insert image description here

Then you need to generate a tsconfig.json file at this location.
Just copy this command:

tsc --init

Then the tsconfig.json file will be generated in the tsDemo folder.

Modify tsconfig.json configuration

Drag the tsDemo folder to vsCode. , find tsconfig.json,
Remove the comment of the line I selected and save it.

insert image description here

Then select the ts file and click: Terminal => Run Build Task. Click tsc: monitor

insert image description here

Then a js folder will be generated in the terminal, which contains the js file compiled from the ts file.
It's done, give yourself a round of applause🎉🎉🎉

insert image description here

Possible errors

tsc: Unable to load file C:\Users\JMQ\AppData\Roaming\npm\tsc.ps1,
Because running scripts is prohibited on this system. For more information, see
about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.

Solution :

Run vscode as administrator.

insert image description here

Then enter in the terminal:

set-executionpolicy remotesigned

It won't report an error.

ps: Let's take a look at how vscode executes typescript files.

1. Execute the tsc xxx.ts command in the vscode console to convert it to xxx.js

2. Execute node xxx.ts to output the result

This is the end of this article about the detailed steps of setting up the TypeScript environment and deploying it to VSCode. For more information about setting up the TypeScript environment, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • TypeScript uses vscode to monitor the code compilation process
  • How to edit TypeScript with VsCode
  • VSCode development TypeScript implementation steps

<<:  CSS3 realizes draggable Rubik's Cube 3D effect

>>:  MySQL query redundant indexes and unused index operations

Recommend

How to use Baidu Map API in vue project

Table of contents 1. Register an account on Baidu...

Inspiring Design Examples of Glossy and Shiny Website Design

This collection showcases a number of outstanding ...

The implementation process of long pressing to identify QR code in WeChat applet

Preface We all know that the QR codes in official...

Javascript basics about built-in objects

Table of contents 1. Introduction to built-in obj...

A brief analysis of the differences between undo, redo and binlog in MySQL

Table of contents Preface 【undo log】 【redo log】 【...

Let's talk in detail about how the NodeJS process exits

Table of contents Preface Active withdrawal Excep...

The background color or image inside the div container grows as it grows

Copy code The code is as follows: height:auto !im...

RGB color table collection

RGB color table color English name RGB 16 colors ...

960 Grid System Basic Principles and Usage

Of course, there are many people who hold the oppo...

js to achieve a simple lottery function

This article shares the specific code of js to im...

Solution to Linux server graphics card crash

When the resolution of the login interface is par...

Universal solution for MySQL failure to start under Windows system

MySQL startup error Before installing MySQL on Wi...

Summary of front-end knowledge in the Gokudō game

background In the early stages of learning Japane...

Use vue3 to implement a human-cat communication applet

Table of contents Preface Initialize the project ...

What are the usages of limit in MySQL (recommended)

SELECT * FROM table name limit m,n; SELECT * FROM...