In some third-party code I found a strange type definition which I didn't see before.
type SomeType = [from: number, to: number];
No idea how this is called in docs so I could not find anything about it. Can someone explain me please what does it mean?
PS. const q: SomeType = [1, 2];
compiles just fine so I guess it's still a simple array of two numbers.
CodePudding user response:
It is Labeled tuple elements
Treat labels from
and to
just as a comments. They don't affect type itself in any way. It is just for readability.