TypeScript 5.2 beta brings explicit resource management

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 bulletinExplicit 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.

A production release of TypeScript 5.2 is due August 22, following a release candidate planned for August 8. The TypeScript 5.2 beta can be accessed through NuGet or via NPM:

npm install -D typescript@beta

Other 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, and reduce 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.

Copyright © 2023 IDG Communications, Inc.


Source link