Explain 'Exhaustive Checking' using the 'never' type.

Updated May 4, 2026

Short answer

Exhaustive checking is a technique to ensure all possible cases in a union are handled by assigning the remaining value to a 'never' type.

Deep explanation

When working with Discriminated Unions, you want to be sure that your logic handles every possible member. By adding a 'default' case in a switch statement that assigns the variable to a constant of type never, the compiler will throw an error if a new member is added to the union later but not handled in that switch. This provides a compile-time guarantee of completeness.

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 →