It's hard to know exactly what you need to change without seeing the particularities of your setup. That said, here are some ideas for you and a demo project. There is also a good conversation in this GitHub issue. The following is a minimal TypeScript project setup that works on my machine.
.vscode/launch.json Set the program
, prelaunchTask
, outFiles
, and sourceMaps
properties.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/index.ts",
"cwd": "${workspaceRoot}",
"preLaunchTask": "tsc",
"outFiles": [
"${workspaceRoot}/**/*.js"
],
"sourceMaps": true
}
]
}
.vscode/settings.json Tell Visual Studio Code to use the TypeScript version that we've installed in our node_modules
instead of using the global installation of TypeScript.
{
"typescript.tsdk": "./node_modules/typescript/lib"
}
.vscode/tasks.json Define the tsc -p .
shell command, which is the prelaunchTask
that we defined in launch.json
.
{
"command": "tsc",
"isShellCommand": true,
"args": ["-p", "."]
}
index.ts
console.log('foo');
console.log('bar'); // a breakpoint here gets hit.
package.json Install TypeScript locally, to give us more control over the version that we use.
{
"devDependencies": {
"typescript": "^2.1.4"
}
}
tsconfig.json Tell the compiler to generate source maps.
{
"compilerOptions": {
"target": "es5",
"sourceMap": true
}
}
sourceMap
on tsconfig.json? – Hagan