1. Preserved Narrowing in Closure Functions
Prior to TypeScript 5.4, type narrowing performed in an outer scope was frequently wiped clean inside nested closure callbacks. TypeScript 5.4 now tracks variable assignments to preserve accurate narrowed types within inner functions.
2. The NoInfer Utility Type
When writing generic TypeScript functions, TypeScript sometimes infers generic type parameters from unexpected argument positions. The NoInfer<T> helper explicitly blocks inference on designated arguments.
function createPalette<C extends string>(colors: C[], defaultColor?: NoInfer<C>) {
// ...
}
// Error caught! 'purple' is not assignable to 'red' | 'blue'
createPalette(['red', 'blue'], 'purple');
3. Auto-Import Improvements in IDEs
TypeScript 5.4 significantly improves auto-import indexing speed, offering near-instant module import suggestions even in multi-gigabyte monorepositories.
