
TypeScript 5.2 is now available in a beta release. The next planned update of Microsoft’s strongly typed JavaScript, TypeScript 5.2 supports the explicit resource management feature planned for JavaScript’s ECMAScript standard.
TypeScript 5.2 reached a beta phase on June 30, according to a Microsoft bulletin. Explicit resource management is intended to address a common pattern in software development regarding the lifetime and management of resources such as IO and memory.
The key idea is to support resource disposal – clean-up work as a first-class idea in JavaScript. This begins with adding a new built-in symbol called Symbol.dispose
. For convenience, TypeScript defines a new global type called Disposable
.
A production release of TypeScript 5.2 is due on August 22, following a release candidate planned for August 8. The beta can be accessed through NuGet or via NPM:
npm install -D typescript@beta
Other capabilities planned for TypeScript 5.2 include:
- Decorator metadata, also an upcoming ECMAScript feature, is implemented, intended to make it easy for decorators to create and consume metadata on any class they are used on or within.
- In the named and anonymous tuple elements vein, an all-or-nothing restriction on tuple labels has been lifted. The language now can preserve labels when spreading into an unlabeled tuple.
- Object member completions are provided when a comma is missing. Previously, if a comma were forgotten and auto-completion requested, TypeScript would confusingly give poor unrelated completion results.
- Easier method usage is offered for unions of arrays.
- A refactoring has been added to inline the contents of a variable to all usage sites. Using the “inline variable” refactoring will eliminate the variable and replace all the variable’s usages with its initialiser.