TypeScript · Senior · Question 29 of 75

What does (typeof users)[number] return if users: 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].

Further reading

Problem with a question

TypeScript · Senior · question 29

Test yourself

Take the TypeScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz