TypeScript 5.4 Adds NoInfer Type
Written by Ian Elliot
Tuesday, 12 March 2024

TypeScript 5.4 has been released, with the addition of a NoInfer utility type alongside preserved narrowing in closures following last assignments.

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. TypeScript can use this information to help you avoid about mistakes like typos, missing arguments, or forgetting to check for null and undefined.


The new NoInfer utility type solves a potential problem when calling generic functions. TypeScript tries to infer type arguments from whatever you pass in, but it's not always clear what the type would be best as the choice to infer. The new NoInfer<T> utility type can be used to signal to TypeScript not to try and match against the inner types to find candidates for type inference.

The addition of preserved narrowing in closures following last assignments means that when TypeScript has worked out a more specific type for a variable based on checks that you perform (type narrowing), that type is preserved in function closures.

The next improvement is the addition of declarations for JavaScript's new Object.groupBy and Map.groupBy static methods. Object.groupBy takes an iterable. It also takes a function that groups all the elements by making a key for each distinct group. Object.groupBy uses that key to make an object where every key maps to an array with the original element in it. Map.groupBy is similar, but produces a Map instead of a plain object.

Other improvements in this version include TypeScript checking the import attributes and assertions against the ImportAttribute type; and better handling of functions that are called with too many arguments.

TypeScript 5.4 is available now.

More Information

TypeScript On NuGet

TypeScript On GitHub

Related Articles

TypeScript 5 - Smaller, Simpler, Faster

TypeScript 4.7 Adds Node.js ECMAScript Module Support

TypeScript 4.6 Improves Constructors

TypeScript 4.5 Adds Awaited

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

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.


Mico - A Personality For Copilot
24/10/2025

Microsoft has designed an animated face for Copilot, its ubiquitous AI Assistant. Is Mico, whose name rhymes with "pico", going be a worthy successor to Clippy, the highly annoying paperclip that trie [ ... ]



Linkerd Adds MCP Support
06/11/2025

Buoyant, the creators of the Linkerd open source and service mesh for the enterprise, have announced the addition of support for Model Context Protocol (MCP) in Linkerd to extend its core service mesh [ ... ]


pico book

Comments




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

Last Updated ( Tuesday, 12 March 2024 )