
Microsoft introduced the beta for TypeScript 5.0, the following main launch of the JavaScript-based programming language.
With 5.0, Microsoft is working to make the language smaller, easier, and quicker. For instance, the 5.0 beta takes 81% of the time to construct VS Code that might take TypeScript 4.9 to take action.
These efficiency enhancements had been doable as a result of TypeScript was lately migrated to modules from namespaces. This enables it to leverage extra fashionable construct tooling.
In TypeScript 5.0, Microsoft is implementing the upcoming ECMAScript (a JavaScript customary) characteristic Decorators. This new characteristic permits builders to customise lessons and members and reuse them. They can be utilized on strategies, properties/fields, getters, setters, and auto-accessors.
In keeping with Microsoft, there was assist for “experimental” decorators for years, and whereas these have been helpful to builders, they had been modeled after an outdated model of the decorators proposal and required an opt-in compiler flag: – -experimentalDecorators. This flag will nonetheless be supported for now, however the change is that decorators will now work even with out that flag.
The corporate additionally famous that the brand new Decorators characteristic gained’t be appropriate with — emitDecoratorMetadata, however there could also be future ECMAScript proposals that bridge the hole in code that makes use of this.
One other factor to notice about ECMAScript’s Decorator proposal is that it requires a category decorator following any “export” key phrase that’s current. TypeScript will implement this in JavaScript recordsdata, however not in TypeScript recordsdata. The explanation for that is that it offers a neater migration path between unique “experimental” decorators and the brand new customary decorators.
Different updates on this launch embrace:
- The “extends” subject has been up to date to allow configuration from a number of config recordsdata.
- A “const” modifier may be added to kind parameter declarations.
- All enums will now be thought of union enums. That is achieved by creating a novel kind for every laptop member. The results of that is that each one enums
- New choices for enabling or disabling options based mostly on configuration
- Help for “export kind *”
A full record of updates may be discovered right here.