Implement the decorator metadata proposal (#3760)
This release implements the decorator metadata proposal, which is a sub-proposal of the decorators proposal. Microsoft shipped the decorators proposal in TypeScript 5.0 and the decorator metadata proposal in TypeScript 5.2, so it's important that esbuild also supports both of these features. Here's a quick example:
// Shim the "Symbol.metadata" symbol
Symbol.metadata ??= Symbol('Symbol.metadata')
const track = (_, context) => {
(context.metadata.names ||= []).push(context.name)
}
class Foo {
@track foo = 1
@track bar = 2
}
// Prints ["foo", "bar"]
console.log(Foo[Symbol.metadata].names)
⚠️ WARNING ⚠️
This proposal has been marked as "stage 3" which means "recommended for implementation". However, it's still a work in progress and isn't a part of JavaScript yet, so keep in mind that any code that uses JavaScript decorator metadata may need to be updated as the feature continues to evolve. If/when that happens, I will update esbuild's implementation to match the specification. I will not be supporting old versions of the specification.