1

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.

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.