TypeScript · Senior · Question 49 of 75

What does T[keyof T] return for T = { a: string; b: number }?

Explanation

Indexed access by a union of keys gives a union of value types. It's often used to get the union of a constant object's values: typeof obj[keyof typeof obj].

Further reading

Problem with a question

TypeScript · Senior · question 49

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