Assertion functions validate conditions at runtime and narrow types, throwing errors when assertions fail.
Basic Assertion Functions
Type Assertion Functions
Object Type Assertions
Array Assertions
Combining with Type Guards
Class Instance Assertions
Validation Chains
Form Validation
API Response Validation
Environment Assertions
Error Handling
Best Practices
Conclusion
Assertion functions validate conditions at runtime and narrow TypeScript types in a single operation. Use them when validation failure should throw an error, unlike type guards which return boolean for conditional paths. Create specific assertion functions for your domain types, use descriptive error messages, and consider custom error types for better error handling. Combine with type guards when you need both validation patterns.