Essentially, VS Code allows you to create tasks for automating development processes (cleaning files / folders, compiling, grouping, etc.), and also allows you to create environment configurations to launch your project.
For them to work together, the configuration of the environment allows you to specify preLaunchTask, which will run a given task before debugging. To create a workflow similar to Visual Studio, you can create a compilation task and run the task before the debugger by setting it as preLaunchTask.
An example of tsc (TypeScript compiler) execution before debugging
1. Create a tsconfig.json file in the root directory of your project using your compilation options.
Example tsconfig.json (you may need to change the module settings to best suit your project. Amd is usually a web project, commonjs is usually node.js , but all preferences vary:
{ "compilerOptions": { "target": "es6", "module": "amd", "sourceMap": true, "allowSyntheticDefaultImports": true }, "exclude": [ "node_modules", "bower_components", "jspm_packages", "tmp", "temp" ] }
2. Create a launch.json file to launch and debug the project and install preLaunchTask in tsc.
The easiest way to do this is to just press F5. At the first start, he will ask "Choose environment", if you have already created the launch.json file and want to start a new one, delete the file. For TypeScript, I usually choose node.js , which allows you to run in the process or inside a web context with frameworks such as express .
Example launch.json file (this example applies to express ):
{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "node", "request": "launch", "program": "${workspaceRoot}/bin/www", "stopOnEntry": false, "args": [], "cwd": "${workspaceRoot}", "preLaunchTask": "tsc", "runtimeExecutable": null, "runtimeArgs": [ "--nolazy" ], "env": { "NODE_ENV": "development" }, "console": "internalConsole", "sourceMaps": false, "outDir": null } ] }