<aside> 📌 튜플은 각 요소 자리에 타입이 고정된 배열이다.

</aside>

const tuple: [number, boolean, string] = [1, false, '3'];
tuple[0] = 3;
tuple[2] = 5; // Type 'number' is not assignable to type 'string'
tuple[3] = '4'; // Type '"4"' is not assignable to type 'undefined'
tuple.push('5');

push 를 사용할 수 없게 하는 튜플

<aside> 📌 타입을 정의할 때 readonly를 앞에 붙이자

</aside>

const tuple: readonly [number, boolean, string] = [1, true, '2'];
tuple.push('5'); // Property 'push' does not exist on type 'readonly [number, boolean, string]'

튜플은 길이가 고정된 배열은 아니다.

const strNumsBool: [string, ...number[], boolean]
	= ['hi', 1, 2, 3, 4, 10, true];

타입 뒤에 ? 가 있는 튜플

let tuple: [number, boolean?, string?] = [1, true, '2'];
tuple = [3, true];
tuple = [4];
tuple = [5, '6']; // Type 'string' is not assignable to type 'boolean | undefined'