Distributive Omit in TS

Published on

Last updated on

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

type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;

This utility type is especially useful when working with discriminated unions where the standard Omit doesn't distribute properly across union members.