Install the TypeScript compiler
Visual Studio Code includes TypeScript language support, but not the TypeScript compiler TSC. You need to install the TypeScript compiler globally or in the workspace to convert TypeScript source to JavaScript (TSC Helloworld.ts).
The easiest way to install TypeScript is through NPM, the Node.js package manager, with -g indicating a global installation.
The installation
npm install -g typescript
Copy the code
Check the version – If the installation is successful, the version information is displayed
tsc --version
Copy the code
xm@xm-Vostro-3670:~/project$TSC --version version 3.3.3333Copy the code
newHelloWorld
The folder andhello_world.ts
file
mkdir HelloWorld
Copy the code
const text:string = 'hello world';
console.log(text);
Copy the code
New Tsconfig. Json
{
"compilerOptions": {
"target": "es5"."module": "commonjs"."outDir": "out"."sourceMap": true}}Copy the code
The new task
Tenimal->Run Task
choosetsc:build-tsconfig.json
Configuration is complete
Press theF5
An extra out folder is found in the directory. The configuration is “outDir”: “out”, and the DEBUG CONSOLE outputs Hello world.