Home >Development Tools >VSCode >Configuring TypeScript automatic compilation in VSCode
Related recommendations: "vscode tutorial"
Visual Studio Code includes TypeScript language support, but The TypeScript compiler tsc is not included. You need to install the TypeScript compiler globally or in your workspace to convert TypeScript source code to JavaScript (tsc HelloWorld.ts).
The easiest way to install TypeScript is through npm, the Node.js package manager, -g
means global installation.
npm install -g typescript
tsc --version
xm@xm-Vostro-3670:~/project$ tsc --version Version 3.3.3333
HelloWorld
folder and hello_world.ts
Filemkdir HelloWorld
const text:string = 'hello world'; console.log(text);##New Tsconfig.json
{ "compilerOptions": { "target": "es5", "module": "commonjs", "outDir": "out", "sourceMap": true } }
##Configuration completed
found that there is an additional folder in the directory. The configuration is "outDir": "out"
,DEBUG CONSOLE
Output hello world
.
F5
More For programming related knowledge, please visit:
programming videoThe above is the detailed content of Configuring TypeScript automatic compilation in VSCode. For more information, please follow other related articles on the PHP Chinese website!