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
- Partial and Required: Toggling Optionality
- Pick and Omit: Selecting Properties
- Record: Mapping Keys to Value Types
- Readonly, Exclude, Extract, NonNullable