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.

typescriptlogo

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.

typescriptlogo

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.

Banner


Zitadel Announces Funding And Future Plans
21/11/2024

Zitadel has announced a major funding round that will be used to expand technical teams and fund further product development. The company is the creator of an open source project for cloud-native iden [ ... ]



Rust And C++ Should Be Friends?
20/11/2024

The Rust Foundation has just released a statement on Rust and C++ interoperability and Google is ponying up $1 to see that it gets done.


More News

espbook

 

Comments




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