0Pricing
TypeScript Academy · Lesson

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

  1. keyof and Indexed Access Types
  2. Generic Constraints: Narrowing Type Parameters
  3. Conditional Types: T extends U ? X : Y
  4. Distributive Conditional Types
← Back to TypeScript Academy