Per-decorator opt-in for type metadata emit #54493
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
Emit type metadata only for decorators that need it.
π Search Terms
decorator metadata
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Note: This might be non-viable under the checklist because it require type-based emit, but type metadata for decorators is already type-based emit, so maybe this is an area where it's ok...
Currently, the
emitDecoratorMetadata
flag emits metadata for every decorated field, even though many decorators might not need that metadata, which can cause bloat.The compiler could instead look at some statically available metadata about the decorator itself, so that the decorator can opt-in to type metadata. This opt-in could be part of the type of the decorator function, ie you have to cast the decorator to a type that signals the decorator needs metadata:
π Motivating Example
Any program that uses a combination of decorators that need type metadata and those that don't.
π» Use Cases
Workarounds are difficult here. Maybe developers can create separate projects and try to isolate those that require type metadata, but that might not always be possible - there might be single files that uses both decorators that require type-metadata and decorators that don't.
cc @rbuckton
The text was updated successfully, but these errors were encountered: