Skip to content

TypeScript type metadata symbols and interfaces #3148

Closed
@remojansen

Description

@remojansen

I have some questions about the metadata symbols that are added by the TypeScript compiler to the generated JavaScript code when using the --emitDecoratorMetadata flag and decorators.

I'm aware of:

  • "design:type" [The serialized form of the type of ?] the decorator target
  • "design:paramtypes" [The serialized form of ?] the return type of the decorator target if it is a function type, undefined otherwise.
  • "design:returntype" A list of [serialized ?] types of the decorator target’s arguments if it is a function type, undefined otherwise.

Is the "design:name" symbol is available?

  • "design:name" The name of the decorator target

I'm hoping to find a symbol that will add the reflect-metadata that I need. I think I'm looking for something that is not available, something like design:implementedtypes or design:interfaces.

What I want to be able to do is be to get the names of the implemented interfaces.

@somedecorator
class Ninja implements INinja, IWarrior {
   // ...
}

The metadata that I would like to be added by the compiler is something would be something like the following:

Reflect.metadata("design:implementedtypes", ["INinja","IWarrior "]);

As an alternative (I don't know if that is the case) it would be OK for me if the "design:type" added the interfaces as well.

Reflect.metadata("design:type", ["Ninja", "INinja","IWarrior"]);

Also, are the serialized form of the types emitted?

reflect.metadata("design:type", ["Ninja"]);

or the actual types?

reflect.metadata("design:type", [Ninja]);

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions