Paul Krill
Editor at Large

TypeScript 4.5 arrives with Promise improvements

news
Nov 18, 20212 mins

Latest GA release of Microsoft’s strongly typed JavaScript introduces new Awaited utility type to model Promise recursions, defers ECMAScript module support for Node.js to a future release.

wood block type
Credit: Getty Images

TypeScript 4.5, the latest upgrade to Microsoft’s strongly typed language based on JavaScript, is now generally available.

The release features a new utility type, the Awaited type, for modeling operations such as await in async functions or the .then() method on Promise objects. However, another capability originally planned for TypeScript 4.5, support for ECMAScript modules in Node.js 12, has been deferred to a later version of TypeScript.

Node.js, which can work with TypeScript, has been working to support ECMAScript modules (ESM), which enable packaging of JavaScript code for reuse. This work has been difficult because Node.js was built on a different module system, CommonJS, Microsoft said. But ESM was largely implemented in Node.js 12.

TypeScript 4.5 reached the release candidate stage on November 2 and became generally available on November 17. Developers can install TypeScript 4.5 through NuGet or via NPM:

npm install typescript

Also new in TypeScript 4.5:

  • A performance regression has been added in --build mode due to excessive realpath calls for JSON files.
  • The release introduces an easy way to override a specific built-in lib to better support the lib setting from node_modules.
  • To improve speed, a system-native implementation of the Node.js realpathSync function is now leveraged on all operating systems. Previously, it was limited to Linux. Now it has been adapted to OSes that are typically case-sensitve, like Windows and MacOS.
  • Snippet completions are offered for JSX attributes.
  • An ECMAScript proposal for checking whether an object has a private field is supported. Another ECMAScript proposal, for import assertions, also is supported. This is a syntax used by runtimes to ensure that an import has an expected format.
  • Better editor support is offered for unresolved types.
  • Values that have template strings can be narrowed. Also, template strings are recognized as discriminants.
  • A new module setting, es2022, is supported, providing top-level await, meaning developers can use await outside of async functions.
  • Some tail-recursion elimination is performed on conditional types.
  • Part of TypeScript 4.5 allows a type modifier on individual named imports.

TypeScript builds on JavaScript by adding syntax for static types. The previous TypeScript release, TypeScript 4.4, became generally available in August.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author