TypeScript · Senior · Question 29 of 75
What does (typeof users)[number] return if users: User[]?
- ✓Correct answer:
User - 2
number - 3
User[]
Explanation
Indexed access by number returns the array element type or a union of tuple element types. A popular combo: const roles = [...] as const; type Role = (typeof roles)[number].