// Taken from https://stackoverflow.com/questions/55539387/deep-omit-with-typescript /** Union of primitives to skip with deep omit utilities. */ type Primitive = string | Function | number | boolean | Symbol | undefined | null /** Deeply omit members of an array of interface or array of type. */ export type DeepOmitArray = { [P in keyof T]: DeepOmit } /** Deeply omit members of an interface or type. */ export type DeepOmit = T extends Primitive ? T : { [P in Exclude]: //extra level of indirection needed to trigger homomorhic behavior T[P] extends infer TP ? // distribute over unions TP extends Primitive ? TP : // leave primitives and functions alone TP extends any[] ? DeepOmitArray : // Array special handling DeepOmit : never } /** Deeply omit members of an array of interface or array of type, making all members optional. */ export type PartialDeepOmitArray = Partial<{ [P in Partial]: Partial> }> /** Deeply omit members of an interface or type, making all members optional. */ export type PartialDeepOmit = T extends Primitive ? T : Partial<{ [P in Exclude]: //extra level of indirection needed to trigger homomorhic behavior T[P] extends infer TP ? // distribute over unions TP extends Primitive ? TP : // leave primitives and functions alone TP extends any[] ? PartialDeepOmitArray : // Array special handling Partial> : never }>