9

I'm new to VSCode and I use it for debugging node.js(Typescript) code. Something that I notices it that if my code stops in a breakpoint and then I use the option "Step Over" or "Step Into", the code goes to the post-compiled Javascript file, instead of the relevant Typescript file.

Do you know how to make the debugger go only to Typescript files as a result of using "Step into" / "Step over"?

My settings.json file look this way:

{
            "type": "node2",
            "request": "launch",
            "name": "Launch TS Program",
            "program": "${workspaceFolder}\\app.ts",
            "preLaunchTask": "tsc: build - tsconfig.json",
            "outFiles": [
                "${workspaceFolder}\\**\\*.js"
            ],
            "smartStep": true,
            "outputCapture": "std",
            "console": "internalConsole",
        },
1
  • did you find the solution for it? Commented Nov 28, 2019 at 4:01

3 Answers 3

3

Try to set smartStep to true in your launch config file (launch.json).

You can find more information about this option in the documentation here.

With the smartStep attribute set to true in a launch configuration, VS Code will automatically skip 'uninteresting code' when stepping through code in the debugger. 'Uninteresting code' is code that is generated by a transpiling process but is not covered by a source map so it does not map back to the original source.

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

1 Comment

'smartStep' is already set to true, and unfortunately it doesn't help :-(
2

I had the same issue. I set the following option in my tsconfig.json and then deleted the directory specified by outDir in tsconfig.json.

{
  ...
 "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
  ...
}

Then when the project was rebuilt on the next debug, the stepping operations seemed to work fine.

Comments

0

Updated

maybe try to toggle the Enable Source Mapped Stepping in debugger

  • @command:extension.js-debug.enableSourceMapStepping
    @command:extension.js-debug.disableSourceMapStepping

enter image description here

enter image description here


Old answer & may be wrong

(Might not be relevant, but this worked for me, idk why)

Maybe you can try to open this single project (/ folder) in a new workspace -- with no other projects / folders, just this single one.

And then run the code.

  • My situation is bit diff -- once I ran the code, the debugger directly jumps to the compiled ts file (yes, a ts file not js, idk why).

    • (I am using tsx to run the ts code.)
  • I guess this may due to vscode has some config that tries to search from the default root project dir -- but unable to correctly locate it if you have multi projects in your workspace.

  • (feels everything was fine for me before, till now.)

Comments

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.