Decorators, an upcoming ECMAScript feature, allow classes and their members to be customized in a reusable way, Microsoft noted in a blog post announcing the RC. Decorators can be used on methods, properties, getters, setters, and auto-accessors. Classes can be decorated for subgrading and enrolling. While TypeScript previously supported experimental decorators, these were modeled after a much older version of the decorators proposal. TypeScript 5.0 will allow decorators to be placed before or after export and export by default, a change made since the January 26 beta of the new release.
Also in TypeScript 5.0, developers can now add a
const modifier to a type parameter declaration to cause
const-type inferences are the default. The update also now allows the
extends to accept multiple inputs, and it turns all enumerations into enumerations by creating a unique type for each calculated member. This means that all enumerations can be collapsed and their members are referenced as types.
TypeScript 5.0 features changes in code structure, data structures, and algorithmic extensions, intended to speed up the entire experience of using TypeScript, even installation. Overall, TypeScript 5.0 is intended to make the language smaller, faster, and simpler. Another change since the beta: new bundler module resolution option now can only be used when the
--module option is set to
esnext. This ensures that
import instructions written in input files will not be transformed into
require calls before the consolidator resolves them.
No other changes are expected in TypeScript 5.0 except for critical bug fixes. TypeScript 5.0 release candidate can be accessed via NuGet or by running the following command:
npm install typescript@rc
Also in TypeScript 5.0:
- Better support is offered for ESM (ECMAScript module) projects in Node and bundlers.
–-verbatimModuleSyntaxThe ability simplifies imports and exports, maintaining imports or exports without
typemodifier while dropping anything using the
- A new JSDoc tag,
- Accuracy changes and write-downs are proposed for less used indicators.
- TypeScript now targets ECMAScript 2018. For Node users, this means a minimum required version of at least Node.js 10.
Copyright © 2023 IDG Communications, Inc.