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


Advent Of Code 2024 Now Underway
01/12/2024

December 1st is much anticipated among those who like programming puzzles. It is time to start solving small but tricky puzzles on the Advent of Code website with the goal of amassing 50 stars by Chri [ ... ]



OpenSilver Adds XAML Designer For Visual Studio Code
12/12/2024

OpenSilver 3.1 has been released. This version adds a drag-and-drop XAML designer for Visual Studio Code (VS Code), a new modern UI theme, and expanded support for WPF features. The open-source altern [ ... ]


More News

espbook

 

Comments




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