VsCode and TypeScript<!-- --> | <!-- -->Patrick Desjardins Blog
Patrick Desjardins Blog
Patrick Desjardins picture from a conference

VsCode and TypeScript

Posted on: May 19, 2016

Visual Studio Code has a good article about how to configure VsCode and TypeScript but I wanted to give more detail about how to setup everything in a more straight forward way. This article talks about how to use VsCode in a way that every time you save a TypeScript file that this one generate the JavaScript and mapping automatically. It also have the advantage to do quick change while running NodeJs because NodeJs doesn't need to be closed and re-started.

.vscode folder

The VsCode folder is a folder located at the root folder of your project. This folder lets you add configuration files in Json format. One file that can be used is named tasks.json and is used for running task. This is where we will create the task runner for TypeScript.


To do so, hit "F1" key and type "Configure Task Runner". This will create for you the tasks.json file under .vscode folder.


You can put he following code:

2 // See http://go.microsoft.com/fwlink/?LinkId=733558
3 // for the documentation about the tasks.json format
4 "version": "0.1.0",
5 "command": "tsc",
6 "isShellCommand": true,
7 "args": ["-p", "."],
8 "showOutput": "silent",
9 "problemMatcher": "$tsc"

VSCode Shortcut

From there, you can use the default hotkey to run the task : Ctrl+Shift+B. However, you can also bind that key on save. This way, everytime you save your file, TypeScript will be compiled into JavaScript. To do so, you can change you VsCode keybinding located in your user profile.


You can all on ctrl+s the command "tasks build".

2 { "key": "ctrl+s", "command": "workbench.action.tasks.build" }

TypeScript Configuration

Next thing is to add TypeScript configuration into a tsconfig.json file. This file is located at the root of your project, at the same level where reside your package.json (npm). My TypeScript configuration contains a "jsx" mention only because I am using React and TypeScript.

2 "compilerOptions": {
3 "target": "ES6",
4 "module": "amd",
5 "sourceMap": true,
6 "jsx": "react",
7 "experimentalDecorators": true,
8 "emitDecoratorMetadata": true,
9 "declaration": false,
10 "noImplicitAny": false,
11 "removeComments": true,
12 "noLib": false,
13 "preserveConstEnums": true,
14 "suppressImplicitAnyIndexErrors": true
15 }

You can have some problem to compile your TypeScript if you have this one already installed in your Program Files. VsCode already have TypeScript installation, so you do not need to have any other installation on your machine.