0Pricing
TypeScript Academy · Lesson

Record: Mapping Keys to Value Types

Build dictionary-like types with Record .

Welcome

Record creates an object type with specific keys K and a uniform value type V. It replaces manually typing every key in dictionary-like structures.

Basic Record Syntax

Pass a key type and value type to Record.
type Roles = Record<'admin' | 'user' | 'guest', boolean>;
const access: Roles = { admin: true, user: true, guest: false };

All lessons in this course

  1. Partial and Required: Toggling Optionality
  2. Pick and Omit: Selecting Properties
  3. Record: Mapping Keys to Value Types
  4. Readonly, Exclude, Extract, NonNullable
← Back to TypeScript Academy