Skip to content

Emit serialized design-time type metadata for decorators #2577

Closed
@rbuckton

Description

@rbuckton

Add support behind an experimental compiler option to emit design-type metadata for decorated declarations in source.

  • Add __metadata helper that depends on a polyfill for a proposed Reflect.metadata decorator.
  • Emit calls to __metadata for class and member (property and method) decorators
  • For a class declaration, emit the type metadata for constructor parameters of the constructor with a body.
  • For a method declaration, emit the type metadata for the member, its parameters, and its return type.
  • For an accessor or property declaration, emit the type metadata for the member.
  • Add compiler option to enable experimental metadata support.

A few notes on metadata:

  • Type metadata uses the metadata key "design:type".
  • Parameter type metadata uses the metadata key "design:paramtypes".
  • Return type metadata uses the metadata key "design:returntype".

Metadata

Metadata

Assignees

Labels

In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions