What does `type Tail = T extends [any, …infer Rest] ? Rest : never` compute?

TypeScript Professional Hard

TypeScript Professional — Hard

What does `type Tail = T extends [any, …infer Rest] ? Rest : never` compute?

Key points

  • The computation removes the first element from a tuple type.
  • It uses conditional types to check if the input type extends a tuple.
  • If the condition is met, it returns the rest of the tuple; otherwise, it returns `never`.

Ready to go further?

Related questions