Skip to content

Incomplete Metadata for subclass with default constructor #13410

Closed
@ajafff

Description

@ajafff

TypeScript Version: 2.1.4

tsc is run with --experimentalDecorators and --emitDecoratorMetadata

Code

function foo(_: any) {}

@foo
class Foo {
    constructor(public bar: number) {}
}
@foo
class Bar extends Foo {
}

Expected behavior:

 Bar = __decorate([
     foo,
-    __metadata("design:paramtypes", [])
+    __metadata("design:paramtypes", [Number])
 ], Bar);

Metadata for subclass with default constructor should include parameter types of super constructor.

Actual behavior:

tsc emit:

/* ... helper functions ... */

function foo(_) { }
var Foo = (function () {
    function Foo(bar) {
        this.bar = bar;
    }
    return Foo;
}());
Foo = __decorate([
    foo,
    __metadata("design:paramtypes", [Number])
], Foo);
var Bar = (function (_super) {
    __extends(Bar, _super);
    function Bar() {
        return _super.apply(this, arguments) || this;
    }
    return Bar;
}(Foo));
Bar = __decorate([
    foo,
    __metadata("design:paramtypes", [])
], Bar);

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