TypeScript 5.2 is now available in a production release. The newly arrived update of Microsoft’s strongly typed JavaScript supports the explicit resource management feature planned for JavaScript’s ECMAScript standard.
TypeScript 5.2 arrived August 24, according to a Microsoft bulletin. It follows an August 9 release candidate and a beta phase that began June 30.
Explicit resource management is intended to address a common pattern in software development regarding the lifetime and management of resources such as I/O and memory. The key idea is to support resource disposal, or 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
.
Since the release candidate (RC), Microsoft documented three additions to TypeScript 5.2: copying array methods, the ability to use symbols as WeakMap
and WeakSet
keys, and clickable inlay parameter hints, which provide parameter definitions at a glance. The release also documents a “small” breaking change around always emitting the namespace keyword in declaration files.
With the RC, Microsoft had added optimized checks for ongoing type compatibility and the ability to reference the paths of TypeScript implementation files in type-only imports.
The TypeScript 5.2 release candidate can be accessed through NuGet or via NPM:
npm install -D typescript
Previously cited new capabilities in TypeScript 5.2:
- Decorator metadata, also an upcoming ECMAScript feature, is intended to make it easy for decorators to create and consume metadata on any class they are used on or within.
- An all-or-nothing restriction on the use of 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 unrelated completion results.
- Easier method usage for unions of arrays means that methods like
filter
,find
,some
,every
, andreduce
can be invoked on unions of arrays in cases where they previously did not work. - 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 initializer.