TypeScript 4.0 Beta: Variadic Tuple Types

TypeScript 4.0 brings variadic tuple types and labeled tuples. Better type inference and DX.

Variadic Tuples

type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U];
type Result = Concat<[1, 2], [3, 4]>; // [1, 2, 3, 4]

Labeled Tuples

type Point = [x: number, y: number, z?: number];
// Better editor hints

References


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.