Types when destructuring arrays
This is the proper syntax for destructuring an array inside an argument list:
function f([a,b,c]: [number, number, number]) {}
Yes, it is. In TypeScript, you do it with types of array in a simple way, creating tuples.
type StringKeyValuePair = [string, string];
You can do what you want by naming the array:
function f(xs: [number, number, number]) {}
But you wouldn't name the interal parameter.Another possibility is use destructuring by pairs:
function f([a,b,c]: [number, number, number]) {}
With TypeScript 4.0, tuple types can now provide labels
type Range = [start: number, end: number]