Created
September 13, 2024 20:33
-
-
Save its-monotype/6a897d0e2469fc0be456fa4e8eed8324 to your computer and use it in GitHub Desktop.
OmitDeep TS utility type
This file contains hidden or 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
export type OmitDeep<T, K extends string> = T extends undefined | |
? undefined | |
: K extends `${infer Head}.${infer Tail}` | |
? Head extends keyof T | |
? { | |
[P in keyof T]: P extends Head ? OmitDeep<T[P], Tail> : T[P]; | |
} | |
: T | |
: Omit<T, K>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment