midTypeScript
What is the 'satisfies' operator and how does it differ from type assertions?
Updated May 4, 2026
Short answer
The 'satisfies' operator validates that an expression matches a type without changing the resulting type of the expression.
Deep explanation
Type assertions (as Type) tell the compiler 'trust me, I know what I'm doing', which can hide errors. Standard type annotations (: Type) force a wider type onto an object, potentially losing specificity. 'satisfies' checks that an object fulfills a contract but preserves the most specific type possible (including literal types), which is useful for property access later.
Real-world example
Ensuring a configuration object has all required keys while still being able to use the literal values of those keys in the application.
Common mistakes
- Using 'satisfies' when you actually want to widen a type to a generic interface.
Follow-up questions
- When should you use 'as const' vs 'satisfies'?