HomeAmir Hossein Shekari (Vanenshi)

DistributiveOmit

Custom omit type that omits a property from all members, preserving union types.

  • #typescript
distributive-omit.ts
export type DistributiveOmit<T, U> = T extends any
  ? Pick<T, Exclude<keyof T, U>>
  : never

Tweet this snippet

Edit on github

Amir Hossein Shekari

Passionate UI engineer looking to bridge the gap between design and code

All rights reserved © Amir Hossein Shekari 2024