On this page
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
- Validates a value against a type WITHOUT widening it (TS 4.9+): Unlike
: Record<string, string>,satisfieskeeps exact keys and literal value types for autocomplete.
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
- tuts/typescript/builtins/as_const Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/typeof Linked here; links to this page; shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins Linked here; links to this page; shared tags: #builtins, #typescript, #web
- tuts/typescript/type_system/structural_typing_and_narrowing Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #builtins, #tier, #typescript, #web
- tuts/typescript/builtins/keyof shared tags: #builtins, #tier, #typescript, #web