元组类型中的剩余元素

版本新特性 / TypeScript 3.0

// *** before: ***
// a variable length tail could not be described by a tuple type,
// so you fell back to an array and lost the types of the head elements
type Args = [string, ...any[]];

// *** in version 3.0: ***
type StringNumberBooleans = [string, number, ...boolean[]];
const a: StringNumberBooleans = ["hello", 1, true, false, true];
// a[0] is string, a[1] is number, a[2] and on are boolean