Decorators, an upcoming ECMAScript feature, let you customize classes and their members 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 subclassing and logging. While TypeScript previously supported experimental decorators, these were modeled on a much older version of the decorator proposal. TypeScript 5.0 will allow decorators to be placed before or after export and default export, a change made since the new version’s January 26 beta release.
Also in TypeScript 5.0, developers can now add a
const modifier to a type parameter declaration to cause
const-like inferences to be the default. The update now also allows the
extends field to take multiple inputs, and makes all enums join by creating a unique type for each computed member. This means that all enumerations can be reduced and their members referenced as types.
TypeScript 5.0 introduces changes to code structure, data structures, and algorithmic extensions, intended to speed up the entire experience of using TypeScript, including installation. Overall, TypeScript 5.0 aims to make the language smaller, faster, and simpler. Another change from the beta: the new package module resolution option can now only be used when the
--module option is set to
esnext. This ensures that
import statements written to input files will not be transformed into
require calls before the wrapper resolves them.
No further changes are expected in TypeScript 5.0, except for critical bug fixes. The 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 provided for ESM (ECMAScript Module) projects in Node and bundlers.
–-verbatimModuleSyntaxcapacity simplifies imports and exports, keeping imports or exports without a
typemodifier while dropping anything using the
- A new JSDoc tag,
- Correction changes and deprecations are offered for less used flags.
- TypeScript now targets ECMAScript 2018. For Node users, this means a minimum version requirement of at least Node.js 10.
TypeScript 5.0 follows the November release of TypeScript 4.9, which featured a
satisfies operator to detect errors. TypeScript turned 10 years old in October 2022.
Copyright © 2023 IDG Communications, Inc.
Be First to Comment