Q41: What is the `satisfies` operator and how does it differ from type annotations?

Difficulty:MediumTopic:Type Operators

The satisfies operator validates that an expression matches a target type contract without widening or modifying the inferred type of the expression.

satisfies vs Type Annotation
type Colors = 'red' | 'green' | 'blue';
type RGB = [r: number, g: number, b: number];

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

// Preserves specific inferred types!
palette.green.toUpperCase(); // Valid! Inferred as string
palette.red.map(x => x);      // Valid! Inferred as RGB tuple
💡 satisfies validates structural conformance while retaining precise literal inference.
Key Takeaways
  • satisfies validates dynamic object structures while preserving precise type inference.