0

From Visual Studio Code, I am able to debug and step through the TypeScript source of Main.ts, provided the JavaScript and map files coexist in the same folder as the TypeScript source.

This arrangement works -

debugDemo\
     .vscode
              launch.json        
     TypeScript\
               Main.ts
               Main.js
               Main.js.map

However, I don't want the JavaScript files in the TypeScript folder, but instead would like the JavaScript in the JavaScript folder. I understand this can be achieved via a launch.json configuration using the outFiles attribute to identify where to locate the JavaScript.

For me, this arrangement does not work -

debugDemo\
     .vscode
              launch.json        
     TypeScript\
               Main.ts
    JavaScript\        
               Main.js
               Main.js.map

The error is always - "Cannot launch program 'c:\debugDemo\TypeScript\Main.ts'; setting the 'outFiles' attribute might help"

enter image description here What is wrong, how can I configure Visual Studio Code to look for the JavaScript files in the JavaScript folder? I experimented with various glob patterns for outFiles, but it did not help resolve the issue.

Main.ts Reduced to one line of code to reduce the problem complexity

  console.log("debug"); 

Mapfiles built via

tsc --sourcemap TypeScript/Main.ts

which generates - TypeScript\Main.js , TypeScript\Main.js.map

launch.json

   {
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Test",
            "program": "${workspaceRoot}/TypeScript/Main.ts",
            "cwd": "${workspaceRoot}",
            "outFiles": ["${workspaceRoot}/JavaScript/**/*.js"],
            "sourceMaps": true
        }
    ]
}
  • TypeScript version: 2.1.4
  • Node version: 6.9.4
  • Visual Studio Code version: 1.14.2

1 Answer 1

1

Your command tsc --sourcemap TypeScript/Main.ts does not output the files into JavaScript folder. You have to specify the outDir and specify the JavaScript folder:

tsc --sourcemap --outDir "JavaScript"  TypeScript/Main.ts

See TypeScript compiler options.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I manually copied the JavaScript files. That was my mistake. The generated map files are now of the form "sources":["../TypeScript/Main.ts"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.