Record<K,V>

A utility type that constructs an object type with keys of type K and values of type V.

Syntax

typescript
Record<Keys, Type>

Example

typescript
type Subject = "math" | "science" | "english";
type Grade = Record<Subject, number>;

const grades: Grade = { math: 95, science: 88, english: 91 };

const cache: Record<string, unknown> = {};

type RouteHandlers = Record<string, () => void>;