The method of using ts in vscode
This article is about the use of ts in vscode. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.
Steps:
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 to initialize, you will find more tsconfig.json file in the root directory, recording the option to compile into JS.
3, open the file, you will find that the main options have been set for you, the more common settings are:
(1)"target": what specification is compiled, 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 to enter the directory, press Ctrl+shift+B shortcut key to compile, the first compilation will select compile mode.
Monitor mode is automatically compiled whenever TS file changes, build mode is compiled when manual command is compiled, here select monitor mode.
5. Press F5 to start debugging. The initial debugging will let you choose the debugging environment.
This is chosen according to the host environment of your JS, and this article uses the NODE environment.
6. There is a configuration button above the debugging button. Click to modify the debugging in detail.
Thank you for reading! About vscode in the use of ts method to share here, I hope the above content can have some help for everyone, so that we can learn more knowledge. If you think the article is good, you can share it so that more people can see it!