keyof and Indexed Access Types
Access object property types dynamically with keyof and T[K].
Welcome
keyof produces a union of an object type's property names. Indexed access types (T[K]) retrieve the type at a specific property key.
keyof Basics
keyof T returns a union of all property name types of T.
interface User { id: number; name: string; email: string; }
type UserKeys = keyof User; // 'id' | 'name' | 'email'All lessons in this course
- keyof and Indexed Access Types
- Generic Constraints: Narrowing Type Parameters
- Conditional Types: T extends U ? X : Y
- Distributive Conditional Types