Skip to content

ES5 async/await sourcemap issue #14506

Closed
Closed
@roblourens

Description

@roblourens

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions