https://type-level-typescript.com/arrays-and-tuples
런타임 동작을 바꾸진 않고 그냥 구분용. optional도 가능함.
Named Indices
The Tuple syntax allows giving names to indices. Just like with objects, names precede values, and names and values are separated by a colon :
character:
type User = [firstName: string, lastName: string];
Names help disambiguate the purpose of values of the same type, which makes them pretty useful. They help us understand the kind of data we are dealing with but they don’t affect the behavior of the type-checker in any way.
Optional indices
A lesser-known feature of tuples is their ability to have optional indices! To mark an index as optional, you only need to add a question mark ?
after it:
type OptTuple = [string, number?];
// ^ optional index!
const tuple1: OptTuple = ["Bob", 28]; // ✅
const tuple2: OptTuple = ["Bob"]; // ✅
const tuple3: OptTuple = ["Bob", undefined]; // ✅
// ^ we can also explicitly set it to `undefined`