Syntax

Basic

var nameNumber: [string, number];
var name: string;
var num: number;
 
// Okay
nameNumber = ['Jenny', 8675309];
 
// Error!
nameNumber = ['Jenny', '867-5309'];
 
var [name, num] = nameNumber;

Rest elements

Rest elements can occur anywhere in a tuple, not just at the end:

type Strings = [string, string];
type Numbers = [number, number];
 
// [string, string, number, number, boolean]
type StrStrNumNumBool = [...Strings, ...Numbers, boolean];

Labels

type Range = [start: number, end: number];
type Foo = [first: number, second?: string, ...rest: any[]];