Skip to content

Instantly share code, notes, and snippets.

@LeandrodeLimaC
Created March 21, 2024 16:42
Show Gist options
  • Save LeandrodeLimaC/3db73b68c1e2a50f35d6a467a6aa6c10 to your computer and use it in GitHub Desktop.
Save LeandrodeLimaC/3db73b68c1e2a50f35d6a467a6aa6c10 to your computer and use it in GitHub Desktop.
A utility type that omits specified keys from an object type in a distributive manner. It uses conditional types to distribute the operation over each property in `T`.
/**
* A utility type that omits specified keys from an object type in a distributive manner.
* It uses conditional types to distribute the operation over each property in `T`.
*
* @template T - The input object type.
* @template TOmitted - The keys to be omitted from the input type.
*/
export type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any
? Omit<T, TOmitted>
: never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment