Skip to content

[Emitter] Wrong design:type metadata for decorated fields #4364

Description

@pcan

When I compile this code:

class A {
    constructor() { console.log('new A'); }
}

type AType = A;

function decorator(target: Object, propertyKey: string) {
}

export class B {

    @decorator
    x: AType = new A();
}

The emitter produces the following code:

var A = (function () {
    function A() {
        console.log('new A');
    }
    return A;
})();
function decorator(target, propertyKey) {
}
var B = (function () {
    function B() {
        this.x = new A();
    }
    __decorate([
        decorator, 
        __metadata('design:type', Object)
    ], B.prototype, "x");
    return B;
})();
exports.B = B;

But the expected output for metadata should be __metadata('design:type', A). Furthermore, if I change the param declaration to x: A = new A();, the emitter will output __metadata('design:type', ) (type not specified at all).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions