버전이 올라감에 따라, 가장 개선이 많이 된 타입.
// Declare a tuple type
let x: [string, number];
// Initialize it
x = ["hello", 10]; // OK
// Initialize it incorrectly
x = [10, "hello"]; // Error
x[3] = "world"; // Error, [ts] Type '"world"' is not assignable to type 'undefined'. [2322], [ts] Property '3' does not exist on type '[string, number]'. [2339]
console.log(x[5].toString()); // Error, [ts] Object is possibly 'undefined'. [2532], [ts] Property '5' does not exist on type '[string, number]'. [2339]
x[6] = true; // Error, [ts] Type 'true' is not assignable to type 'undefined'. [2322], [ts] Property '6' does not exist on type '[string, number]'. [2339]
const person: [string, number] = ['mark', 35];
const [name, age] = person;