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


Women Who Code Closing For Lack of Funding
24/04/2024

Women Who Code the US-based non-profit organization that since its foundation in 2011 has advocated for women and diversity in technology, has announced its imminent closure due to critical funding cu [ ... ]



FORTRAN and COBOL Re-enter TIOBE Index
17/05/2024

The TIOBE Index sets out to reflect the relative popularity of  computer languages so it comes as something of a surprise to see two languages dating from the 1950's in this month's Top 20.


More News

raspberry pi books

 

Comments




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