Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Type Alias

Record

Record<Keys, Type> constructs an object type whose keys come from Keys and whose values all use Type. It is useful for strongly typed dictionaries and lookup tables.

Since
2.1

How it works

Record<Keys, Type> creates an object type with one property for every key in Keys, assigning Type as the value type for each property. It is useful when a known set of property names must all share a value shape.

Syntax

Record<Keys, Type>

Parameters

NameTypeDescription
KeysKeysThe property-key type used to determine the object’s keys.
TypeTypeThe type assigned to every property in the resulting object.

Returns

An object type with properties keyed by Keys and values of Type.

Key points

  • Record<Keys, Type> maps a key type to a common value type, producing an object type with those properties.
  • It is useful for expressing dictionaries and lookup tables whose entries share a defined value shape.
  • A generic Record can preserve a known key set while transforming each value from one type to another.

Example: A typed lookup table

type Page = "home" | "about" | "contact";

type PageInfo = {
  title: string;
  url: string;
};

const pages: Record<Page, PageInfo> = {
  home: { title: "Home", url: "/" },
  about: { title: "About", url: "/about" },
  contact: { title: "Contact", url: "/contact" }
};

console.log(pages.about.url);

The union supplies the required keys, while PageInfo describes the value stored under each key.

When to use it

Complete lookup tables

Represent a finite set of named entries, such as routes or feature flags, while requiring every declared key.

Uniform dictionary values

Give every property in a key union the same object, primitive, or function value type.

Key-preserving value transformations

Transform values associated with a known key set from one type to another.

Interview questions

QWhat does Record<K, T> represent?

Record<K, T> describes an object whose keys are K and whose values are T. If K is a union, each member becomes a required property in the resulting object type.

Follow-up: How does Record differ from a mapped type over an existing type? Record creates properties from its key type rather than copying properties and their modifiers from an input type.

QHow can Record enforce a complete lookup table?

A union such as "home" | "about" | "contact" constrains the permitted property names. The value type is applied uniformly to every one of those properties.

Follow-up: What happens when a key is omitted from an object assigned to Record<K, T>? The assignment fails because the mapped key set requires that property.

QWhen was Record introduced and where is it available?

Record is globally available as a TypeScript utility type and was released in TypeScript 2.1. It is intended for common object-type transformations and does not require an import.

Follow-up: When would an index signature be less precise? An index signature can allow arbitrary keys, whereas Record with a literal-key union restricts the object to the declared key set.

  • Pick
  • Partial
  • Readonly
  • mapped types
  • index signatures

Source: Documentation - Utility Types - TypeScript. Checked 2026-10-15.