sig*_*a54 5 typescript visual-studio-code vscode-debugger
尝试调试 mts 文件时,我很难获取要绑定的断点。代码运行并输出正确的结果(在本例中只是一堆 console.log 语句)有趣的是,如果我首先转到生成的 mjs 文件并在该文件中插入一个断点,它将在 mts 中拾取断点文件。如果 mjs 文件中没有断点,则调试器不会附加。
设置:
{
"type": "node",
"request": "launch",
"name": "Launch Debug",
"program": "${workspaceFolder}/lib/src/debug.mjs",
"preLaunchTask": "tsc: build - tsconfig.debug.json"
}
Run Code Online (Sandbox Code Playgroud)
{
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"module": "ES2020",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"typeRoots": ["./types", "./node_modules/@types"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.mts"],
"exclude": ["node_modules", "types"]
}
Run Code Online (Sandbox Code Playgroud)
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"sourceMap": true,
"outDir": "lib"
}
}
Run Code Online (Sandbox Code Playgroud)
有没有人能够在不将 package.json 类型设置设置为 module 的情况下调试 mts 文件,或者我应该向 Typescript 团队提交问题吗?
我想到了!我需要将 "pauseForSourceMap": true 添加到我的启动配置中,如下所示:
{
"type": "node",
"request": "launch",
"name": "Launch Debug",
"program": "${workspaceFolder}/lib/src/debug.mjs",
"preLaunchTask": "tsc: build - tsconfig.debug.json",
"pauseForSourceMap": true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
667 次 |
| 最近记录: |