Created
March 21, 2024 16:42
-
-
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`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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