简体   繁体   English

在 VS Code 中调试 React TypeScript

[英]Debug React TypeScript in VS Code

I've created an ASP Core project with React TypeScript template.我用 React TypeScript 模板创建了一个 ASP Core 项目。 Unfortunately, it is very hard to debug it since in jumps between the TypeScript code and the generated JavaScript code.不幸的是,很难调试它,因为它在 TypeScript 代码和生成的 JavaScript 代码之间跳转。

For example:例如:
在此处输入图像描述

After one step it arrives to:一步之后,它到达:
在此处输入图像描述

Which is the generated JS code that I want to avoid when I debug.这是我在调试时想要避免的生成的 JS 代码。 My launch.json contains that Chrome debugger configuration:我的launch.json包含 Chrome 调试器配置:

"configurations": [
    {
        "name": ".NET Core Launch (web)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        // If you have changed target frameworks, make sure to update the program path.
        "program": "${workspaceFolder}/WebApplication1/bin/Debug/netcoreapp2.1/WebApplication1.dll",
        "args": [],
        "cwd": "${workspaceFolder}/WebApplication1",
        "stopAtEntry": false,
        "launchBrowser": {
            "enabled": false
        },
        "sourceFileMap": {
            "/Views": "${workspaceFolder}/Views",
        }
    },
    {
        "name": "Chrome",
        "type": "chrome",
        "request": "launch",
        "url": "https://localhost:5001",
        "webRoot": "${workspaceFolder}/WebApplication1/ClientApp/src",
        "userDataDir": "${workspaceFolder}/.vscode/chrome",
        "sourceMapPathOverrides": {
            "webpack:///./src/*": "${webRoot}/*",
        }
    }

How can I debug this TypeScript code without the generated JavaScript?如何在没有生成的 JavaScript 的情况下调试此 TypeScript 代码? BTW, Same behavior happens also in Visual Studio 2019.顺便说一句,同样的行为也发生在 Visual Studio 2019 中。

Add "smartStep": true to your launch.json configuration."smartStep": true添加到您的 launch.json 配置中。

https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_smart-stepping https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_smart-stepping

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM