Skip to content

Typescript does not emit names in sourcemap. This breaks this -> _this hover when debugging #14688

Description

@nojvek

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)
v2.2.1
Code

// A *self-contained* demonstration of the problem follows...
const test = (inp: string[]) => {
    console.log(this);
    for (let str of inp) {
        console.log(str);
    }
}

test(['1', '2', '3', '4'])

output:

var _this = this;
var test = function (inp) {
    console.log(_this);
    for (var _i = 0, inp_1 = inp; _i < inp_1.length; _i++) {
        var str = inp_1[_i];
        console.log(str);
    }
};
test(['1', '2', '3', '4']);
//# sourceMappingURL=blah.js.map

Sourcemap:

{"version":3,"file":"blah.js","sourceRoot":"","sources":["blah.ts"],"names":[],
"mappings":"AAAA,iBAO0B;AAP1B,IAAM,IAAI,GAAG,UAAC,GAAa;IACvB,OAAO,CAAC,GAAG,CAAC,KAAI,CAAC,CAAC;IAClB,GAAG,CAAC,CAAY,UAAG,EAAH,WAAG,EAAH,iBAAG,EAAH,IAAG;QAAd,IAAI,GAAG,YAAA;QACR,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACpB;AACL,CAAC,CAAA;AAED,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA"}

Expected behavior:
names:[] should be filled with the transpiled names. This breaks debuggers that try to show values when hovering over the variable name. In many cases this in scope refer to _this or _this1 or _this12.

See microsoft/vscode#12066 (comment)

Having names would aid VSCode in giving a better experience for debugging transpiled typescript output

Actual behavior:

names is always empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions