type Tuple = [number, string]
const example: Tuple = [1, "message"]
const example2: Tuple = ["messsage", 1] // Type 'string' is not assignable to type 'number'.
type tIncorrect = [id: number, string]; // INCORRECT, 2nd element has no name, compile-time error.
type tCorrect = [id: number, msg: string]; // CORRECT, all have a names.
提示:如果你不确定最后一个元素的计数,你可以这样写:
type t = [msg: string, ...indexes: number];// means first element is a message and there are unknown number of indexes.