【发布时间】:2017-05-29 10:17:06
【问题描述】:
我已经检查了以下答案:
How to debug async/await in visual studio code?
但是两者都没有解决我的问题。
我希望能够使用 Node.js v7.4.0 从 VSCode 调试本机 Async/Await,而无需使用可怕的 Typescript 转译版本。我能够让 Typescript 输出正确的代码,即没有 __awaiter 等。但是,一旦我尝试调试代码,所有转译的状态机代码都会出现!?所以我可以调试代码,它只是不是我要调试的代码。有没有办法阻止被调试的代码有转译的状态机代码?
这是我的配置文件:
tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"noImplicitAny": false,
"sourceMap": true,
"outDir": "lib",
"noUnusedParameters": false,
"noUnusedLocals": false,
"skipLibCheck": true
//"importHelpers": true
},
"exclude": [
"node_modules"
]
}
launch.json
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false,
"cwd": "${workspaceRoot}",
//"preLaunchTask": "tsc",
"runtimeExecutable": null,
"args": [
"--runInBand"
],
"runtimeArgs": [
"--harmony-async-await",
"--no-deprecation"
],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/{lib}/**/*.js"
],
"skipFiles": [
"node_modules/**/*.js",
"lib/**/*.js"
]
}
为了进一步说明我的意思,这里是输出 javascript 中的一段 sn-p 代码:
let handler = subscription.messageSubscription.handler;
debugger;
await handler(message.message, context);
但是调试时它看起来像这样:
case 4:
handler = subscription.messageSubscription.handler;
debugger;
return [4 /*yield*/, handler(message.message, context)];
case 5:
【问题讨论】:
标签: javascript node.js typescript visual-studio-code