VSCode Debugger&Typescript:Step Over / Into转到JS文件

问题描述 投票:3回答:2

我是VSCode的新手,我用它来调试node.js(Typescript)代码。我注意到,如果我的代码在断点处停止,然后我使用选项“Step Over”或“Step Into”,代码将转到后编译的Javascript文件,而不是相关的Typescript文件。

您是否知道如何使用“Step into”/“Step over”使调试器仅转到Typescript文件?

我的settings.json文件看起来像这样:

{
            "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",
        },
typescript visual-studio-code
2个回答
1
投票

尝试在启动配置文件(smartStep)中将true设置为launch.json

您可以在文档here中找到有关此选项的更多信息。

在启动配置中将smartStep属性设置为true时,VS代码将在调试器中逐步执行代码时自动跳过“不感兴趣的代码”。 “不感兴趣的代码”是由转换过程生成但未被源映射覆盖的代码,因此它不会映射回原始源。


0
投票

我遇到过同样的问题。我在tsconfig.json中设置了以下选项,然后删除了outDirtsconfig.json指定的目录。

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

然后,当在下一次调试中重建项目时,步进操作似乎工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.