typescript-satisfies-operator
TypeScript: The satisfies Operator
Core Concept
The satisfies operator validates that an expression matches a type without changing the inferred type. This is different from type annotations (:) which widen the type.
Key insight from Matt Pocock:
- "When you use a colon, the type BEATS the value"
- "When you use
satisfies, the value BEATS the type"
Type Annotation vs Satisfies
type RoutingPathname = "/products" | "/cart" | "/checkout";
// Type annotation - widens to union
const url1: RoutingPathname = "/products";
// url1 is typed as: RoutingPathname (wide)
More from flpbalada/my-opencode-config
progressive-disclosure
Reduce complexity by revealing information progressively. Use when designing
56social-proof-psychology
Leverage social proof principles to build trust and influence user behavior.
39react-useeffect-avoid
Guides when NOT to use useEffect and suggests better alternatives. Use when reviewing React code, troubleshooting performance, or considering useEffect for derived state or form resets.
38trust-psychology
Build trust signals that reduce perceived risk and enable user action. Use
37five-whys
Conduct root cause analysis using the Five Whys technique. Use when
34cognitive-fluency-psychology
Apply cognitive fluency principles to improve clarity, trust, and conversion.
32