Skip to content

Emit of union type metadata in nullStrictMode is always Object #12703

@dqweek

Description

@dqweek

TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)

function annotation(): PropertyDecorator {
    return (target: any, key: string | symbol): void => { };
}

class A {

    @annotation()
    field: B | null | undefined;
}

class B {
    field1: number;
}

Expected behavior:


function annotation() {
    return function (target, key) { };
}
var A = (function () {
    function A() {
    }
    __decorate([
        annotation(), 
        __metadata('design:type', B)
    ], A.prototype, "field", void 0);
    return A;
}());
var B = (function () {
    function B() {
    }
    return B;
}());

Actual behavior:


function annotation() {
    return function (target, key) { };
}
var A = (function () {
    function A() {
    }
    __decorate([
        annotation(), 
        __metadata('design:type', Object) //<-- should be B
    ], A.prototype, "field", void 0);
    return A;
}());
var B = (function () {
    function B() {
    }
    return B;
}());

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions