0Pricing
TypeScript Academy · Lesson

Keyof and Lookup Types

Discover how to extract and reference keys and properties from existing types, enabling dynamic and reusable type definitions.

1

Introduction to Keyof and Lookup Types

The keyof and lookup types in TypeScript allow you to work dynamically with keys and properties of existing types.

They make your code more flexible and reusable by letting you reference and extract types from objects.

Keyof and Lookup Types — illustration 1

2

What is keyof?

The keyof operator creates a type consisting of all the keys of an object type.

Example:

type Person = {
  name: string;
  age: number;
};
type PersonKeys = keyof Person;

All lessons in this course

  1. Keyof and Lookup Types
  2. Mapped Types
  3. Intersection and Union Types
← Back to TypeScript Academy