Discriminated Unions are one of TypeScript's most powerful patterns—especially for API responses and Redux/React state. Give every object in a union a shared literal tag field (like status or type), and TypeScript automatically knows which fields exist inside each switch or if branch!
ADVERTISEMENT