On this page
  1. satisfies
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

satisfies

Prev: `typeof` | Up: builtins | Next: `as const`
Rel: builtins, Structural Typing & Narrowing
Ref: TypeScript Docs — satisfies
Tags: #public #web #typescript #builtins #tier/core


Syntax & Overview

const palette = { red: '#f00' } satisfies Record<string, string>;

Validates that an expression matches a target type without widening its inferred literal/specific type.

Notes & Pitfalls

Example

const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
} satisfies Record<string, string | [number, number, number]>;

palette.red.map((n) => n / 255);     // TS knows `red` is a tuple
palette.green.toUpperCase();         // TS knows `green` is a string

Linked from

Related notes