TkDodo
Read post

Omit for Discriminated Unions in TypeScript

TypeScript's built-in Omit utility type breaks discriminated unions by treating them as a whole rather than distributing over each union member. This causes type errors when building wrapper components that depend on discriminated union props. A distributive version using conditional types (T extends any ? Omit<T, K> : never) preserves the union structure by applying Omit to each member individually. This solution also provides stricter type checking by constraining keys to those that actually exist on the type.

    #react#typescript
Nov 24, 2025•7m read time•From tkdodo.eu
Post cover image
Table of contents
Discriminated Union TypesDistributive Conditional TypesDistributive OmitLimited Keys
31.1K Impressions
TkDodo's image
TkDodo

TK Dodo is a platform dedicated to sharing insights and resources on software development, technolog...

184 Followers

•

1.4K Upvotes

tkdodo's user avatar
Dominik D
@tkdodo
Joined Feb 3. 2021
2.4K

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard