Provide more detailed metadata for decorators · Issue #12577 · microsoft/TypeScript · GitHub
Skip to content

Provide more detailed metadata for decorators #12577

Closed

Description

#Proposal
Current emitted decorator metadata, only contains minimal typing information. My suggestion is to provide detailed information. Such as, nested type (generic type).

Example

1. resolve nested typing.

class A {
    @Foo
    propA: Map<string, Promise<number>>;
    @Bar
    propA: Map<string, Map<List<number>, boolean>>;
    @Baz
    methodA(): Map<Promise<number>, string>;
}

both @Foo's deisng:type and @Foo's design:returntype and each design:paramtypes should be the same.

resulting metadata:

@Foo: [Map, [string, [Promise, [number] ] ] ];
@Bar: [Map, [string, [Map, [ [List, [number] ] , boolean] ] ];
@Baz: [Map, [ [Promise, [number] ] , string] ];

logic:
for any generic type.
Type<...Arguments> -> [Type, [...Arguments]], recursively.

2. Retrieve parameter names

new metadata design:paramnames, in the same order of design:paramtypes.

3. ParamTypes and ParamNames for class decorators

@Foo
class A {
	propA: string;
	methodA(): number;
}

similar to deisng:paramtypes and design:paramnames of a method decorator. It retrieves paramter types and paramnames of each property and function even props were not assigned with a initial value. param type for a method should be Function in this case.

Activity

  1. joesonw commented on Jan 3, 2017

    @joesonw
    Author

    Would this be accepted as a feature? If so, I can submit a PR for this.

  2. mhegazy commented on Apr 27, 2017

    @mhegazy
    Contributor

    Duplicate of #11362

    As noted in #14971 (comment), reflection and runtime type serialization is outside the scope of the TypeScript project in the time being.

    Relevant discussion in #3628.

  3. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions