Explain 'Discriminated Unions' and Exhaustive Checking.

Updated May 4, 2026

Short answer

It uses the 'never' type to ensure every member of a union is handled in a switch or if statement[cite: 1].

Deep explanation

By assigning the remaining variable to never in a default case, the compiler throws an error if a union member is unhandled. This ensures 100% logic coverage at compile-time[cite: 1].

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More TypeScript interview questions

View all →