UNPKG

948 BTypeScriptView Raw
1// Type definitions for object.omit 3.0
2// Project: https://github.com/jonschlinkert/object.omit
3// Definitions by: Ifiok Jr. <https://github.com/ifiokjr>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.8
6
7type Omit<GType, GKeys extends keyof GType> = Pick<GType, Exclude<keyof GType, GKeys>>;
8
9/**
10 * Return a copy of an object excluding the given key, or array of keys. Also accepts an optional filter function as the last argument."
11 *
12 * ```ts
13 * omit({a: 'a', b: 'b', c: 'c'}, ['a', 'c'])
14 * //=> { b: 'b' }
15 * ```
16 *
17 * @param object
18 * @param keys
19 */
20
21declare function omit<GObject extends object, GKey extends keyof GObject>(
22 object: GObject,
23 key: GKey | GKey[],
24): Omit<GObject, GKey>;
25
26declare function omit<GObject extends object, GKey extends keyof GObject>(
27 object: GObject,
28 fn: (value: GObject[GKey], key: GKey, obj: GObject) => boolean,
29): { [key: string]: any };
30
31export = omit;