[TypeScript] Labelled tuple type
Let's see the unlabelled tuple type:
type Address = [
number,
string,
string,
number,
]
function printAddress(...address: Address) {
console.log(address)
}
As you can see, the auto completion is not good.
Then see the labelled tuple types:
type Address_Label = [
streetNumber: number,
streeName: string,
city: string,
postCode: number,
]
function printAddress2(...address: Address_Label) {
console.log(address)
}
Once you label one tuple type, you have to label all the tuple.