Home >Development Tools >VSCode >How to use ts in vscode

How to use ts in vscode

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-12-06 15:51:258150browse

How to use ts in vscode

Steps:

1. Open the command line and type npm i -g typescript to install TS globally.

2. Continue to type tsc -init in the command line environment for initialization. You will find that there is an additional tsconfig.json file in the root directory, which records the options for compiling into JS.

3. When you open the file, you will find that the main options have been set for you. The more commonly used settings are:

(1) "target": what specification to compile to, generally set to ES5 or ES2016/2017;

(2) "outdir": output directory;

(3) "alwaysStrict": turn on strict mode ('use strict');

4. Enter code at the command line. Open VSCode and enter the directory. Press the Ctrl shift B shortcut key to compile. The compilation mode will be selected for the first compilation.

How to use ts in vscode

#Monitoring mode means that the TS file will be compiled automatically whenever there is a change. Build mode means that it will be compiled only when manually commanded to compile. Select the monitoring mode here.

5. Press F5 to start debugging. The first time you debug, you will be asked to select the debugging environment.

How to use ts in vscode

Choose this based on your own JS hosting environment. This article uses the NODE environment.

6. There is a configuration button above the debugging button. Click to make detailed modifications to the debugging.

How to use ts in vscode

PHP Chinese website has a large number of free vscode introductory tutorials, everyone is welcome to learn!

The above is the detailed content of How to use ts in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn