What does `type TupleToUnion = T[number]` accomplish?

TypeScript Professional Hard

TypeScript Professional — Hard

What does `type TupleToUnion = T[number]` accomplish?

Key points

  • `T[number]` accesses the types of each element in the tuple.
  • The resulting type is a union of all individual types.
  • This is useful for scenarios where you need to work with the combined types of a tuple.

Ready to go further?

Related questions