Skip to content

Regression: decorator must be on first of the defined property methods #12554

Closed
@wardbell

Description

@wardbell

TypeScript Version: 2.1.1

In 2.0.10, a decorator such as the Angular @Input decorator could appear on the second of the two methods implementing a defined property. As of 2.1.1, you get an error unless it appears on the first.

Expected behavior:
The code should work as it does when transpiled with 2.0.10

Actual behavior:
The code fails with 2.1.1

Repro
Here is my plunker. Follow the README.

To see that changing the TypeScript version controls the outcome,
open config.js and toggle the TypeScript version to 2.0.10 to see that the code works fine when the decorator is on the second property method.

I compared the generated JS under TS 2.0.10 and 2.1.1.
The latter, failing version is missing the following important code:

  __decorate([
            core_1.Input(), 
            __metadata('design:type', Number)
        ], CustomComponent.prototype, "selectedSection", null);

This explains why the Angular app fails: Angular can't find that decorator and therefore proclaims that the CustomComponent does not have a bindable selectedSection property.

View Angular issue "Setter @Input binding not working after upgrading to 2.2.3 from 2.1.2 " see how this issue arose, That issue is closed because we believe this is actually a TS issue.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions