TypeScript 4.0 Lands, and Variadic Tuple Types Are the Star
TypeScript 4.0 ships with variadic tuple types and labeled tuple elements, unlocking sharper typing for function arguments and array structures.
Microsoft shipped TypeScript 4.0 today, and if you write any nontrivial amount of TypeScript, this is one of those releases worth actually reading the changelog for instead of just bumping the version number and moving on.
The headline feature is variadic tuple types. Up until now, tuples in TypeScript were rigid: you could say “this is an array with exactly these three types in this order,” but you couldn’t easily express “this is some fixed prefix of types, followed by however many of another type.” That sounds like a small gap, but it’s exactly the shape of problem you hit constantly when typing things like function composition helpers, concat/bind/curry style utilities, or anything working with arguments-like spreads. Library authors have been writing increasingly absurd stacks of overloaded function signatures to fake this behavior, and it still fell apart at the edges. Variadic tuples let the type system express “spread this tuple type into another tuple type” directly, which means generic higher-order functions can finally propagate parameter types through wrappers without the author hand-rolling a dozen overloads.
Paired with that is a smaller but very welcome change: labeled tuple elements. You can now write something like [first: string, second: number] instead of just [string, number], so when a function signature or exported type shows up in your editor’s hover tooltip, you actually see meaningful names instead of positional noise. It’s a small ergonomic thing, but it matters a lot for how legible autocomplete and inline docs are, especially on typed function signatures with several parameters of the same type.
Why this matters beyond syntax sugar
Variadic tuples aren’t just a party trick for library authors. They’re the kind of feature that quietly upgrades the ceiling for what “fully typed” JavaScript can express. A lot of the popular utility libraries in the ecosystem — think functional composition helpers, Redux-style middleware chains, React hook wrappers — have had to choose between good type safety and reasonable code size. This closes some of that gap. Expect a wave of “we removed 200 lines of overloads thanks to TS 4.0” changelog entries from popular libraries over the coming weeks.
There’s a broader release alongside these headliners too — this is a .0 release, so there’s the usual bundle of smaller improvements and internal compiler work that will get more attention as people upgrade their projects. But variadic tuples are clearly what the team wanted to lead with, and it’s a legitimate step up in expressiveness rather than a minor point release dressed up as a big one.
If you maintain a library with heavily overloaded function signatures, it’s worth carving out some time this week to see whether variadic tuples let you simplify things. It won’t fix everything, but for the specific pain of “generic function that needs to preserve caller argument shapes,” this is the tool you’ve been waiting for.
In unrelated but very real news for anyone who just wants a solid phone without spending a fortune: Google’s Pixel 4a became widely available today at $349. Nice to have both a compiler release and a hardware release worth paying attention to on the same day.