From 19053aa84e473fab046938bf2648cf7ee5090111 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 7 Dec 2015 04:31:43 +0500 Subject: [PATCH] lodash: signatures of _.pick have been changed --- lodash/lodash-tests.ts | 47 +++++++++++++++++++++++++++++++----------- lodash/lodash.d.ts | 31 +++++++++++++++++++++------- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 9cae2a872..3ad1c37e5 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -7047,18 +7047,41 @@ module TestPairs { } // _.pick -interface TestPickFn { - (element: any, key: string, collection: any): boolean; -} -{ - let testPickFn: TestPickFn; - let result: TResult; - result = _.pick({}, 0, '1', true, [2], ['3'], [true], [4, '5', true]); - result = _.pick({}, testPickFn); - result = _.pick({}, testPickFn, any); - result = _({}).pick(0, '1', true, [2], ['3'], [true], [4, '5', true]).value(); - result = _({}).pick(testPickFn).value(); - result = _({}).pick(testPickFn, any).value(); +module TestPick { + let predicate: (element: any, key: string, collection: any) => boolean; + + { + let result: TResult; + + result = _.pick({}, 'a'); + result = _.pick({}, 0, 'a'); + result = _.pick({}, true, 0, 'a'); + result = _.pick({}, ['b', 1, false], true, 0, 'a'); + result = _.pick({}, predicate); + result = _.pick({}, predicate, any); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _({}).pick('a'); + result = _({}).pick(0, 'a'); + result = _({}).pick(true, 0, 'a'); + result = _({}).pick(['b', 1, false], true, 0, 'a'); + result = _({}).pick(predicate); + result = _({}).pick(predicate, any); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _({}).chain().pick('a'); + result = _({}).chain().pick(0, 'a'); + result = _({}).chain().pick(true, 0, 'a'); + result = _({}).chain().pick(['b', 1, false], true, 0, 'a'); + result = _({}).chain().pick(predicate); + result = _({}).chain().pick(predicate, any); + } } // _.result diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ed8d72443..9c11aedac 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -11771,9 +11771,9 @@ declare module _ { * @param predicate The function invoked per iteration or property names to pick, specified as individual * property names or arrays of property names. * @param thisArg The this binding of predicate. - * @return An object composed of the picked properties. + * @return Returns the new object. */ - pick( + pick( object: T, predicate: ObjectIterator, thisArg?: any @@ -11782,9 +11782,9 @@ declare module _ { /** * @see _.pick */ - pick( + pick( object: T, - ...predicate: Array> + ...predicate: (StringRepresentable|StringRepresentable[])[] ): TResult; } @@ -11792,7 +11792,7 @@ declare module _ { /** * @see _.pick */ - pick( + pick( predicate: ObjectIterator, thisArg?: any ): LoDashImplicitObjectWrapper; @@ -11800,11 +11800,28 @@ declare module _ { /** * @see _.pick */ - pick( - ...predicate: Array> + pick( + ...predicate: (StringRepresentable|StringRepresentable[])[] ): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.pick + */ + pick( + predicate: ObjectIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper; + + /** + * @see _.pick + */ + pick( + ...predicate: (StringRepresentable|StringRepresentable[])[] + ): LoDashExplicitObjectWrapper; + } + //_.result interface LoDashStatic { /**