diff --git a/types/utility.d.ts b/types/utility.d.ts index 60005c2e8b7..016f2c48b07 100644 --- a/types/utility.d.ts +++ b/types/utility.d.ts @@ -2,6 +2,17 @@ declare module 'mongoose' { type IfAny = 0 extends (1 & IFTYPE) ? THENTYPE : ELSETYPE; type IfUnknown = unknown extends IFTYPE ? THENTYPE : IFTYPE; + /** + * @summary Removes keys from a type + * @description It helps to exclude keys from a type + * @param {T} T A generic type to be checked. + * @param {K} K Keys from T that are to be excluded from the generic type + * @returns T with the keys in K excluded + */ + type ExcludeKeys = { + [P in keyof T as P extends K ? never : P]: T[P]; + }; + type Unpacked = T extends (infer U)[] ? U : T extends ReadonlyArray ? U : T;