TypeScript 4.5 Adds Awaited
Thursday, 25 November 2021

TypeScript 4.5 has been released with improvements including support for the Awaited type, improvements to the support promises, and new snippet completions.

TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs.


The headline improvement to TypeScript 4.5 is a new utility type called Awaited. This can be used to model operations like await in async functions, or the .then() method on Promises, and in particular, the way that they recursively unwrap Promises. The developers say the Awaited type can be helpful for modeling existing APIs, including JavaScript built-ins like Promise.all and Promise.race.

The next improvement is support for lib from node_modules. This provides a way to override a specific built-in lib in a manner similar to how @types/ support works, and is designed to overcome problems caused by the use of declaration files to specify which APIs in the JavaScript language and the standard browser DOM APIs your program should use.

Another improvement means that TypeScript 4.5 now can narrow values that have template string types, and also recognizes template string types as discriminants. TypeScript 4.5 also now provides snippet completions when overriding or implementing methods in classes, and for JSX attributes.

type snippets in TypeScript

The new version also has a new feature that carries out tail-recursion elimination on conditional types. The team says that TypeScript needs a way to fail gracefully when it detects possibly infinite recursion, or any type expansions that can take a long time and affect your editor experience. To handle this, TypeScript has heuristics that identify when these problems are occurring, but some valid types trigger the 'potential problem' heuristics. To overcome this, TypeScript 4.5 performs some tail-recursion elimination on conditional types.

Other improvements include Private Field presence checks that work out whether an object has a private field on it; and import assertions that make sure that an import has an expected format.

TypeScript 4.5 is available now.


More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript 4.4 Improves Control Flow Analysis

TypeScript 4.3 Adds Separate Property Write Types

TypeScript 4.2 Release Candidate Available

New TypeScript Website Launched

TypeScript 4.1 Adds Temporal Literal Types

TypeScript 3.0 Adds Project References

TypeScript Adds Unused Span Reporting

TypeScript Adds Conditional Types



To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


SQL Turns 50

The first release of SQL was in June 1974. Designed at IBM by Donald D. Chamberlin and Raymond F. Boyce, it was based on the relational model proposed by E.F. Codd. SQL became the most widely used dat [ ... ]

At What Age Do Programmers Write Languages?

This is just one of many question that can be answered by reference to PLDB, the programming language database devised and maintained by Breck Yunits, himself the author of Scroll, an o [ ... ]

More News

C book



or email your comment to: comments@i-programmer.info