DEV Community

Discussion on: How 2 TypeScript: Get the last item type from a tuple of types

Collapse
 
badhusband profile image
badhusband • Edited

We don't have to rely on getting the length. Use tuple destructuring for a simple one liner:

type Last<T extends any[]> = T extends [...any[], infer R] ? R : never
Enter fullscreen mode Exit fullscreen mode