The satisfies operator validates types while preserving the most specific inferred type. Here's how to use it.
Basic Usage
Type Validation
Preserving Literal Types
Union Types
Configuration Objects
With as const
Event Handlers
Function Return Types
Validation Schemas
Props Definition
Best Practices
Usage:
✓ Validate object structure
✓ Preserve literal types
✓ Keep specific key types
✓ Combine with as const
Benefits:
✓ Better type inference
✓ Compile-time validation
✓ Autocomplete works
✓ Refactoring safety
vs Type Annotation:
✓ satisfies: validates + preserves specifics
✗ Annotation: validates + widens type
Avoid:
✗ Using when annotation suffices
✗ Complex nested satisfies
✗ Forgetting it's TypeScript 4.9+
✗ Using for simple primitives
Conclusion
The satisfies operator validates that a value matches a type while preserving the most specific inferred type. Use it for configuration objects, route definitions, and anywhere you want both type safety and precise type inference. It's particularly powerful with literal types and union types.