
Microsoft introduced the beta for TypeScript 5.0, the subsequent main launch of the JavaScript-based programming language.
With 5.0, Microsoft is working to make the language smaller, less complicated, and quicker. For instance, the 5.0 beta takes 81% of the time to construct VS Code that may take TypeScript 4.9 to take action.
These efficiency enhancements have been doable as a result of TypeScript was lately migrated to modules from namespaces. This enables it to leverage extra trendy construct tooling.
In TypeScript 5.0, Microsoft is implementing the upcoming ECMAScript (a JavaScript customary) function Decorators. This new function permits builders to customise lessons and members and reuse them. They can be utilized on strategies, properties/fields, getters, setters, and auto-accessors.
In accordance with Microsoft, there was assist for “experimental” decorators for years, and whereas these have been helpful to builders, they have 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 function received’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 information, however not in TypeScript information. The rationale for that is that it gives a better migration path between authentic “experimental” decorators and the brand new customary decorators.
Different updates on this launch embody:
- The “extends” discipline has been up to date to allow configuration from a number of config information.
- A “const” modifier might be added to kind parameter declarations.
- All enums will now be thought-about 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 primarily based on configuration
- Assist for “export kind *”
A full record of updates might be discovered right here.