4

TypeScript 5.0 Adds New Changes for Decorators

 1 year ago
source link: https://devm.io/typescript/typescript-5-decorators
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What’s new in the latest release?

TypeScript 5.0 Adds New Changes for Decorators

Sarah Schlothauer

17. Mar 2023


The latest version of TypeScript, Microsoft’s open source superset of JavaScript, has now been released. TypeScript 5.0 adds several new features and changes for the programming language.

One of the current development goals for TypeScript is to make the language a bit easier to use, with improved functionality and a smaller size relative to older versions. This work continues in TypeScript version 5.0, which should improve performance for programmers and streamline some aspects, despite a few small breaking changes. Optimizations have been made for run times and build times, so users can expect to see an increase in speed over the previous release.

Following from the initial Release Candidate’s deployment on March 1, 2023, version 5.0 adds the new decorator standard, improves performance and package file sizes, supports multiple configuration files in extends, and more. Let’s have a quick look at some of the changes and see what’s new and improved.

FigureTypeScript 5: New Innovations and Breaking Changes: Explore all the new changes and latest features in TypeScript 5.0 with Karsten Sitterberg, an Oracle-certified Java developer and Angular, Vue, and React expert. TypeScript 5 presents as a solid release with a focus on optimizations. Especially the new decorators changes will lead to some adjustments for framework developers who have implemented basic functionality with them.

Stage 3 of the ECMAScript Decorators proposal reached

TypeScript 5.0 adds some new implementations for decorators, aligning it with the next stage in the ECMAScript proposal.

Decorators can help you customize how a class and its members (as well as methods, properties, and set/get accessors) function. They can also extend how these work. Decorators have been in an experimental phase in TypeScript for several years now, but TypeScript 5.0 Final changes how they are used a bit, so if you have used decorators during their preview phase, it is recommended that you review what's been changed. According to Microsoft’s release blog notes, the new decorators are not compatible with --emitDecoratorMetadata and no longer allow for decorating parameters.

You can view the original pull request on GitHub for a full history of this proposal, including what is currently supported.

More TypeScript 5.0 changes

  • New support in the extends field: TypeScript 5.0 adds support in the extends field. Users can now support multiple configuration files for multiple entries.
  • enums changes and improvements: In the new version of TypeScript, all enums have now been changed into Union enums. Have a further look at the pull request on GitHub for what this unification entails.
  • Support for export type * added: Improving upon the implementation of type-only imports back in TypeScript version 3.8, version 5 now officially supports this syntax for the export type *.
  • JSDoc support changes: Now, JSDoc will support the @overload, as well as the satisfies operator.
  • Various optimizations: TypeScript 5.0 had a large focus on improving the language’s ease of use and simplifying the codebase and as a result, it tweaked some of its performance too. According to testing, TypeScript can now potentially run 81% faster compared to 4.9. Installation, build time, run time, and startup time are all quicker.
  • Breaking changes: Of course, a new release usually means some breaking changes. Node users will have to update their version to at least Node.js 10. Several API breaking changes have also been made, see the full list on GitHub.

Naturally, this is not the exhaustive list of all new additions in TypeScript 5.0 This major release adds a lot of new improvements for the language. Refer to Karsten Sitterberg’s article TypeScript 5: New Innovations and Breaking Changes for a comprehensive overview of everything new and different in TypeScript 5.0. Karsten Sitterberg will walk you through how each change works in practice using helpful examples.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK