News

What's New in TypeScript 5.2

Microsoft shipped TypeScript 5.2, the latest edition of the popular programming language that adds the optional ability to use type systems when working with JavaScript.

Its host of new features range from better resource management to copying array methods to inline variable refactoring and more.

Microsoft shipped the new version last week after a string of previews, with Daniel Rosenwasser, senior program manager for TypeScript, summarizing the work so far since TypeScript v5.1 shipped in June.

"Since the Beta, we've added a type-checking optimization and made it possible to reference the paths of TypeScript implementation files in type-only imports," he said.

"Since the RC, we've also documented the addition of Copying Array Methods, symbols as WeakMap and WeakSet Keys and Clickable Inlay Parameter Hints. This release also documents a small breaking change around always emitting the namespace keyword in declaration files."

[Click on image for larger view.] Clickable Inlay Parameter Hints (source: Microsoft).

Several of the new features implement functionality introduced in ECMAScript, the standard for JavaScript. One of those is the upcoming Explicit Resource Management feature, described in a GitHub proposal as "a common pattern in software development regarding the lifetime and management of various resources (memory, I/O, etc.). This pattern generally includes the allocation of a resource and the ability to explicitly release critical resources."

Rosenwasser noted that current implementations of the functionality add "noise" to code and could cause other problems. After an exhaustive explanation of the feature, he summarized it this way: "The key idea of the proposal is to support resource disposal -- this clean-up work we're trying to deal with -- as a first class idea in JavaScript."

With the new support enacted by a new built-in symbol called Symbol.dispose, TypeScript will automatically call that disposal method on those resources -- or objects -- when they go out of scope, via using declarations.

Another upcoming ECMAScript feature concerns decorator metadata, which seeks to extend the Decorators proposal (used to extend JavaScript classes) with the added ability for decorators to associate metadata with the value being decorated. "The key idea of this feature is to make it easy for decorators to create and consume metadata on any class they're used on or within," Rosenwasser said.

And yet another ECMAScript feature addressed in TypeScript 5.2 concerns copying array methods, with Rosenwasser explaining that the new version includes definitions for the methods added to ECMAScript in the "Change Array by Copy" proposal. Typically copying arrays requires jumping through some hoops if you want to do so without affecting the original array. That issue is addressed via JavaScript's four new methods to perform various array copying operations without affecting the original data: toSorted, toSpliced, toReversed and with.

Other highlights of the release include:

  • Support for named and anonymous tuple elements
  • Easier method usage for unions of arrays
  • Symbols as WeakMap and WeakSet keys
  • Type-only import paths with TypeScript implementation file extensions
  • Comma completions for object members
  • Inline variable refactoring
  • Optimized checks for ongoing type compatibility
  • Breaking changes and correctness fixes

Going forward, developers can see what's on tap in the TypeScript 5.3 Iteration Plan for the next release, coming Nov 14.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube