From c34b1e67eee7862f1b3ec48e6c8b6878ae8b0500 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 8 Dec 2015 19:12:39 +0500 Subject: [PATCH] lodash: signatures of _.omit have been changed --- lodash/lodash-tests.ts | 48 ++++++++++++++++++------- lodash/lodash.d.ts | 80 +++++++++++++++++++++++------------------- 2 files changed, 80 insertions(+), 48 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index ce60da779..c409e2621 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -7073,19 +7073,43 @@ module TestFunctions { } } -interface HasName { - name: string; +// _.omit +module TestOmit { + let predicate: (element: any, key: string, collection: any) => boolean; + + { + let result: TResult; + + result = _.omit({}, 'a'); + result = _.omit({}, 0, 'a'); + result = _.omit({}, true, 0, 'a'); + result = _.omit({}, ['b', 1, false], true, 0, 'a'); + result = _.omit({}, predicate); + result = _.omit({}, predicate, any); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _({}).omit('a'); + result = _({}).omit(0, 'a'); + result = _({}).omit(true, 0, 'a'); + result = _({}).omit(['b', 1, false], true, 0, 'a'); + result = _({}).omit(predicate); + result = _({}).omit(predicate, any); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _({}).chain().omit('a'); + result = _({}).chain().omit(0, 'a'); + result = _({}).chain().omit(true, 0, 'a'); + result = _({}).chain().omit(['b', 1, false], true, 0, 'a'); + result = _({}).chain().omit(predicate); + result = _({}).chain().omit(predicate, any); + } } -result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); -result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { - return typeof value == 'number'; -}); -result = _({ 'name': 'moe', 'age': 40 }).omit('age').value(); -result = _({ 'name': 'moe', 'age': 40 }).omit(['age']).value(); -result = _({ 'name': 'moe', 'age': 40 }).omit(function (value) { - return typeof value == 'number'; -}).value(); // _.pairs module TestPairs { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 801b66be9..253107c7f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -11842,54 +11842,62 @@ declare module _ { //_.omit interface LoDashStatic { /** - * Creates a shallow clone of object excluding the specified properties. Property names may be - * specified as individual arguments or as arrays of property names. If a callback is provided - * it will be executed for each property of object omitting the properties the callback returns - * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, - * object). - * @param object The source object. - * @param keys The properties to omit. - * @return An object without the omitted properties. - **/ - omit( + * The opposite of _.pick; this method creates an object composed of the own and inherited enumerable + * properties of object that are not omitted. + * + * @param object The source object. + * @param predicate The function invoked per iteration or property names to omit, specified as individual + * property names or arrays of property names. + * @param thisArg The this binding of predicate. + * @return Returns the new object. + */ + omit( object: T, - ...keys: string[]): Omitted; + predicate: ObjectIterator, + thisArg?: any + ): TResult; /** - * @see _.omit - **/ - omit( + * @see _.omit + */ + omit( object: T, - keys: string[]): Omitted; - - /** - * @see _.omit - **/ - omit( - object: T, - callback: ObjectIterator, - thisArg?: any): Omitted; + ...predicate: (StringRepresentable|StringRepresentable[])[] + ): TResult; } interface LoDashImplicitObjectWrapper { /** - * @see _.omit - **/ - omit( - ...keys: string[]): LoDashImplicitObjectWrapper; + * @see _.omit + */ + omit( + predicate: ObjectIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper; /** - * @see _.omit - **/ - omit( - keys: string[]): LoDashImplicitObjectWrapper; + * @see _.omit + */ + omit( + ...predicate: (StringRepresentable|StringRepresentable[])[] + ): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.omit + */ + omit( + predicate: ObjectIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper; /** - * @see _.omit - **/ - omit( - callback: ObjectIterator, - thisArg?: any): LoDashImplicitObjectWrapper; + * @see _.omit + */ + omit( + ...predicate: (StringRepresentable|StringRepresentable[])[] + ): LoDashExplicitObjectWrapper; } //_.pairs