UNPKG

706 BTypeScriptView Raw
1type Omit<GType, GKeys extends keyof GType> = Pick<GType, Exclude<keyof GType, GKeys>>;
2
3/**
4 * Return a copy of an object excluding the given key, or array of keys. Also accepts an optional filter function as the last argument."
5 *
6 * ```ts
7 * omit({a: 'a', b: 'b', c: 'c'}, ['a', 'c'])
8 * //=> { b: 'b' }
9 * ```
10 *
11 * @param object
12 * @param keys
13 */
14
15declare function omit<GObject extends object, GKey extends keyof GObject>(
16 object: GObject,
17 key: GKey | GKey[],
18): Omit<GObject, GKey>;
19
20declare function omit<GObject extends object, GKey extends keyof GObject>(
21 object: GObject,
22 fn: (value: GObject[GKey], key: GKey, obj: GObject) => boolean,
23): { [key: string]: any };
24
25export = omit;