Installing TypeScript for Visual Studio Code

Leave a comment

Visual Studio Code has support for the TypeScript language. To use it, create a new file with TypeScript code in Visual Studio Code:

And save the file, we will see TypeScript as an option:

We can see Visual Studio Code has TypeScript Intellisense:

Visual Studio Code does not include the TypeScript Compiler (tsc). To install it using the Visual Studio Code terminal, type:

npm install -g typescript

You will see TypeScript install:

You can now see which version of TypeScript is installed by entering tsc –version:

Now, create a new file:

Name the file tsconfig.json and add the code:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true
    }
}

Now, from the Tasks build menu, select Run Build Task:

And select tsc: build – tsconfig.json:

The terminal will execute the TypeScript compiler tsc:

Which will compile and produce JS files based on the TS files:

You can also simply type the tsc command to transpile the ts file directly.

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, BI, Web, Cloud and Data Science.

carldesouza.comLinkedIn Twitter | YouTube

 

Leave a Reply

Your email address will not be published. Required fields are marked *