TypeScript debugging in Visual Studio Code with seperate outdir

Putting break points in TypeScript files in Visual Studio Code does not work out of the box when a separate output directory is being utilized for the TypeScript configuration:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noImplicitAny": false,
        "sourceMap": true,
        "outDir": "build/"
    }
}

The break points will not be mapped correctly from the ts files to the js files without additional configuration. To achieve the correct mapping the outFiles property need to be set in VS Codes debugger configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Port",
            "port": 5858,
            "outFiles": [
                "${workspaceRoot}\\build\\**\\*.js"
            ]
        }
    ]
}

 

Leave a Reply

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