Skip to content

Bug with private fields: comment emitted twice #26

Closed
@mheiber

Description

@mheiber

Actual behavior: comment is emitted above the class and inside the constructor
Expected behavior: comment is only emitted above the class

TS:

// i am a comment

class A {
    #b: string = "FFF"
    constructor (public name: string) {
    }
}

JS emit:

// i am a comment
var _classPrivateFieldSet = function (receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; };
var _b_1;
"use strict";
class A {
    constructor(name) {
        // i am a comment
        _b_1.set(this, void 0);
        this.name = name;
        _classPrivateFieldSet(this, _b_1, "FFF");
    }
}
_b_1 = new WeakMap();

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions