TypeScript 4.5 is out with improvements and new snippet completions

The update brings improvements including support for the Awaited type, improvements to the support promises, and new snippet completions.

The update brings 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 main 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 says the Awaited type can be helpful for modeling existing APIs, including JavaScript built-ins like Promise.all and Promise.race.

Next in 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 bothered on the achievement that TypeScript 4.5 now can narrow values that have template string types, and also recognizes template string types as discriminants. The 4.5 also now provides snippet completions when overriding or implementing methods in classes, and for JSX attributes.

The release 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. In handling this, TypeScript uses 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.

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

More Information
2.3/5.0 Article rating
3 Reviews
Was this article helpful?
  1. Great!
  2. Good
  3. Like
  4. Mmh
  5. Pff
Copy link