Microsoft has released the beta version of TypeScript 5.0, with one of the main components being new decorator standards that enable users to customize classes and their members in a reusable way, InfoQ reports.
Daniel Rosenwasser, TypeScript program manager, says in a Microsoft blog post that these experimental decorators were extremely useful, but they modeled an older version and always required a compiler selection flag called –experimentalDecorators. He also stated that developers who used “–experimentalDecorators” were already aware that in the past, any attempt to use decorators in TypeScript without enabling this flag resulted in an error message.
The new decorator offering in TypeScript 5.0 allows developers to write cleaner, more maintainable code with the added benefit of being able to customize classes and their members in a reusable way. Although the new decorator proposal is incompatible with –emitDecoratorMetadata and does not support parameter decoration, Microsoft expects that future ECMAScript proposals may be able to address these limitations.
TypeScript 5.0 also includes several enhancements, such as more precise type checking for parameter decorators in constructors, const annotations, and the ability for the extended field to accept multiple entries. Also included are a new option to resolve modules in TS, performance improvements, and exhaustive switch/case completions.