-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reflect Metadata not supported for TC39 decorators #55788
Comments
AFAIU this is not implemented yet. See #53461. |
Same problem. Lots of libraries use metadata about types, such as Angular, NestJs, class-validator, my library for di. Generating metadata for new decorators is very necessary. |
I am also seeing this issue. Here is the playground link. I have set the |
I think the title of issue needs to be changed to something like Also reviewing the code it looks like it is not implemented here https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/transformers/ts.ts#L1064 |
I also thing that emitting type metadata is very necessary, but now that both Decorators and Decorator Metadata have achieved Stage 3 within TC39 and have been implemented in TS >=5.2, the API proposed in the This is why I think that is better to expose design-time type information in the new TC39 decorator metadata when |
Inclined to agree @artberri. I've raised a PR to serve as a PoC / proposal for how this could be implemented. A lot of the foundations were already set, so this barely required any changes. |
Mark nestjs/nest#11414 |
🔎 Search Terms
decorator, experimentalDecorators, emitDecoratorMetadata, TC39, reflect-metadata, Reflect.metadata(k, v)
🕗 Version & Regression Information
This breaks when setting disabling experimental decorators
⏯ Playground Link
https://github.com/paulsmithkc/typescript-decorators
💻 Code
tsconfig.json
src/index.ts
run with:
🙁 Actual behavior
Reflect.getMetadata('design:type', target, property)
returns undefined.🙂 Expected behavior
Reflect.getMetadata('design:type', target, property)
returns the type of the class field, when using Standard TC39 decorators.Additional information about the issue
When transpiling with:
The decorator
Reflect.metadata("design:type", type)
is automatically applied to each class field.When transpiling with:
The decorator
Reflect.metadata("design:type", type)
is not applied.When transpiling with:
Typescript produces the following error
The text was updated successfully, but these errors were encountered: