-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support to stage 3 #14
Comments
Adding some context for fellow decorator explorers 😄 TypeScript added support for decorator metadata in this PR which is described in their 5.2 release notes. esbuild has also added support for this proposal here. Can anyone from tc39 provide clarity on a few questions here:
This comment from the TS discussion tracking decorator metadata by @EisenbergEffect would seem to imply that the decorator metadata proposal is stage 3 alongside decorators, but I'm not sure the extent to which that's talking about decorators vs decorator metadata. btw I'm currently using the following polyfill for decorator metadata: // https://github.com/microsoft/TypeScript/issues/53461
// symbol-polyfill.ts
declare global {
interface SymbolConstructor {
readonly metadata: unique symbol
}
}
;(Symbol as any).metadata ??= Symbol.for('Symbol.metadata')
const _metadata = Object.create(null)
if (typeof Symbol === 'function' && Symbol.metadata) {
Object.defineProperty(globalThis, Symbol.metadata, {
enumerable: true,
configurable: true,
writable: true,
value: _metadata
})
} Thanks! 🙏 |
It's important the next TC39 meeting session about Decorator Metadata for Stage 3 (slides, spec). We need the decorator metadata because, without it, we have limited the decorator feature.
Especially important is - at least for some teams - to be able to coordinate decorators with metadata, especially the class member decorators, which in this current pattern as mere metadata annotators, and the associated class decorator, which reads from the metadata and performs the necessary transformations and adaptations.
As a workaround, when we use "method", "getter", "setter" or "accessor" decorators, we can put a symbol in each function to put metadata there, but with "field" we don't have a shelf where to put metadata.
Of course, without this feature, work with metadata and inheritance is very complicated.
Consequently, we need the decorator metadata as soon as possible.
The text was updated successfully, but these errors were encountered: