What is the satisfies operator used for in TypeScript?

Answer

The satisfies operator (TypeScript 4.9) addresses the tension between type annotation and type inference. Normally, annotating a variable with a type narrows inference — you lose the specific inferred types of individual properties. Without satisfies: const palette: Record<string, string | number[]> = { red: "#f00", green: [0, 255, 0] }; palette.red.toUpperCase(); // Error! red could be string or number[]. With type assertion: you lose validation. With satisfies: const palette = { red: "#f00", green: [0, 255, 0] } satisfies Record<string, string | number[]>;. Now TypeScript validates the structure matches the type (errors if you add an invalid property), but infers the most specific types for each property: palette.red is string, palette.green is number[]. The satisfies operator is particularly useful for configuration objects, theme tokens, route maps, and any case where you want type validation without losing the specificity of the inferred type.