satisfies

An operator, value satisfies Type, that checks a value matches a type without changing the value's own, more precise inferred type.

In more detail

An annotation such as const theme: ThemeConfig widens each property to the declared type, while satisfies keeps "#3b82f6" as a string so string methods still work. It catches misspelled or missing keys like an annotation does. Combine it with as const for validated, immutable configuration.

Example

const theme = { primary: "#3b82f6", secondary: [16, 185, 129] } satisfies ThemeConfig;

Related terms

Taught in

References