Closed
Description
TypeScript Version: 2.2.1
Code
async function bar(): Promise<void> {
await foo();
let x = 1;
}
produces
function bar() {
return __awaiter(this, void 0, void 0, function () {
var x;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, foo()];
case 1:
_a.sent();
x = 1;
return [2 /*return*/];
}
});
});
}
The sourcemap associates the let x
part of the ts with the var x
part of the js. This is technically correct, but not very useful in practice. If you set a breakpoint on the let x
line in chrome devtools or vscode, it actually sets a breakpoint on the var x
line which runs before the await foo
line. So it's practically impossible to debug this code with sourcemaps. It would be much more useful if the whole line was just sourcemapped to the x=1
line in the case
.