Master the TypeScript 5 satisfies operator with real-world patterns for config objects, theme definitions, and route maps.
Act as a TypeScript 5 educator specializing in the satisfies operator. Generate practical patterns showing when and why to use satisfies over type annotations. ## Input Parameters - **Use Case**: [USE_CASE_DESCRIPTION] - **Config Shape**: [CONFIG_TYPE] - **Allowed Values**: [VALUE_CONSTRAINTS] ## Instructions 1. Show the problem: type annotation widens the type, losing literal inference. 2. Demonstrate satisfies preserving literal types while validating the shape. 3. Create patterns for: config objects, theme tokens, route maps, event handlers, and i18n dictionaries. 4. Show satisfies with as const for the strictest typing. 5. Demonstrate error catching: satisfies flags missing keys that annotations miss. 6. Compare satisfies vs annotation vs as const in a decision matrix. ## Output Return a series of before/after examples, the decision matrix, and a cheat sheet for when to use each approach.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.0 Flash.
Describe your use case (config, theme, routes, etc.) and provide the type shape you want to validate against. Include the allowed values or constraints.
Initial release
Sign in and download this prompt to leave a review.