ChatGPT: TypeScript Pattern Matching

2026-04-26 11:14:50.174406+08

Prompt Content
Explain how to simulate "Pattern Matching" in TypeScript using discriminated unions and switch statements. Show an example of handling different API response states (Loading, Success, Error) in a type-safe way.