Skip to content

Typescript incorrectly emits metadata type 'Object' for custom classes #13098

@pklicnik

Description

@pklicnik

TypeScript Version: 2.1.4

Code

module MyModule {

  export function inject(target: any, key: string): void {}

  export class Leg {}

  export class Person {
    @inject leftLeg: Leg;
  }

}

Compiled with:
tsc --experimentalDecorators --emitDecoratorMetadata -target es5 app.ts

Expected behavior:
The design:type metadata inserted uses type Object instead of the actual type

__decorate([
    inject,
    __metadata("design:type", Object)
], Person.prototype, "leftArm", void 0);

Actual behavior:
The design:type metadata should be set to the correct type (Leg in this case)

__decorate([
    inject,
    __metadata("design:type", Leg)
], Person.prototype, "leftArm", void 0);

Note: This was working in previous version (we were on 1.8.10) and broke after upgrading to 2.1.4

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