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.
标签:TypeScript,string,tuple,address,number,Labelled,Address,type From: https://www.cnblogs.com/Answer1215/p/16612851.html