May 2018 update:
Starting in May 2018, you no longer need to create tsconfig.json manually or configure tsconfig.json tasks.
- Run
tsc --init in your project folder to create the tsconfig.json file (if you don't already have one). - Press Ctrl + Shift + B to open the task list in VS Code and select
tsc: watch - tsconfig.json . - Done! Your project is recompiled every time you save the file.
You can have several tsconfig.json files in your workspace and run several compilations at the same time if you want (for example, frontend and backend separately).
Original answer:
You can do this with the Build commands:
Create a simple tsconfig.json using "watch": true (this will instruct the compiler to view all compiled files):
{ "compilerOptions": { "target": "es5", "out": "js/script.js", "watch": true } }
Please note that the files array is omitted, by default all *.ts files in all subdirectories will be compiled. You can provide any other parameters or change target / out , just make sure watch set to true .
Configure your task ( Ctrl + Shift + P β Configure Task Runner ):
{ "version": "0.1.0", "command": "tsc", "showOutput": "silent", "isShellCommand": true, "problemMatcher": "$tsc" }
Now press Ctrl + Shift + B to build the project. You will see the compiler output in the output window ( Ctrl + Shift + U ).
The compiler will automatically compile files when saved. To stop compilation, press Ctrl + P - > Tasks: Terminate Running Task to stop execution > Tasks: Terminate Running Task
I created a project template specifically for this answer: typescript-node-basic
zlumer May 19 '15 at 7:39 2015-05-19 07:39
source share