Is it possible to maintain type coverage on a function that deeply removes all instances of a key in an object?
My function looks like this.
function
For those coming here with a later version of TS (I've tested this with TS3.8.3), you'll need to inline DeepOmitHelper from Titian's answer.
type Primitive =
| string
| Function
| number
| boolean
| Symbol
| undefined
| null;
type DeepOmitArray = {
[P in keyof T]: DeepOmit;
};
export type DeepOmit = T extends Primitive
? T
: {
[P in Exclude]: T[P] extends infer TP
? TP extends Primitive
? TP // leave primitives and functions alone
: TP extends any[]
? DeepOmitArray // Array special handling
: DeepOmit
: never;
};