From cd55bb6be57148005b7175bafda01cf39cfa1e50 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 11 Nov 2015 20:21:06 +0500 Subject: [PATCH] lodash: signatures of the method _.modArgs have been changed --- lodash/lodash-tests.ts | 69 +++++++++++++++++++++++++++++++----------- lodash/lodash.d.ts | 13 ++++++++ 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4c587b57b..938d6a92d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3840,25 +3840,58 @@ var returnedMemoize = _.throttle(function (a: any) { return a * 5; }, 5); returnedMemoize(4); // _.modArgs -function modArgsFn1(n: number): string {return n.toString()} -function modArgsFn2(n: boolean): string {return n.toString()} -interface ModArgsFunc { - (x: string, y: string): string[]; +module TestModArgs { + type Func1 = (a: boolean) => boolean; + type Func2 = (a: boolean, b: boolean) => boolean; + + let func1: Func1; + let func2: Func2; + + let transform1: (a: string) => boolean; + let transform2: (b: number) => boolean; + + { + let result: (a: string) => boolean; + + result = _.modArgs boolean>(func1, transform1); + result = _.modArgs boolean>(func1, [transform1]); + } + + { + let result: (a: string, b: number) => boolean; + + result = _.modArgs boolean>(func2, transform1, transform2); + result = _.modArgs boolean>(func2, [transform1, transform2]); + } + + { + let result: _.LoDashImplicitObjectWrapper<(a: string) => boolean>; + + result = _(func1).modArgs<(a: string) => boolean>(transform1); + result = _(func1).modArgs<(a: string) => boolean>([transform1]); + } + + { + let result: _.LoDashImplicitObjectWrapper<(a: string, b: number) => boolean>; + + result = _(func2).modArgs<(a: string, b: number) => boolean>(transform1, transform2); + result = _(func2).modArgs<(a: string, b: number) => boolean>([transform1, transform2]); + } + + { + let result: _.LoDashExplicitObjectWrapper<(a: string) => boolean>; + + result = _(func1).chain().modArgs<(a: string) => boolean>(transform1); + result = _(func1).chain().modArgs<(a: string) => boolean>([transform1]); + } + + { + let result: _.LoDashExplicitObjectWrapper<(a: string, b: number) => boolean>; + + result = _(func2).chain().modArgs<(a: string, b: number) => boolean>(transform1, transform2); + result = _(func2).chain().modArgs<(a: string, b: number) => boolean>([transform1, transform2]); + } } -interface ModArgsResult { - (x: number, y: boolean): string[] -} -result = _.modArgs((x: string, y: string) => [x, y], modArgsFn1, modArgsFn2); -result = result(1, true); - -result = _.modArgs((x: string, y: string) => [x, y], [modArgsFn1, modArgsFn2]); -result = result(1, true); - -result = _((x: string, y: string) => [x, y]).modArgs(modArgsFn1, modArgsFn2).value(); -result = result(1, true); - -result = _((x: string, y: string) => [x, y]).modArgs([modArgsFn1, modArgsFn2]).value(); -result = result(1, true); // _.negate interface TestNegatePredicate { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 98d8bf55d..a4b8ba199 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7557,6 +7557,7 @@ declare module _ { interface LoDashStatic { /** * Creates a function that runs each argument through a corresponding transform function. + * * @param func The function to wrap. * @param transforms The functions to transform arguments, specified as individual functions or arrays * of functions. @@ -7588,6 +7589,18 @@ declare module _ { modArgs(transforms: Function[]): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.modArgs + */ + modArgs(...transforms: Function[]): LoDashExplicitObjectWrapper; + + /** + * @see _.modArgs + */ + modArgs(transforms: Function[]): LoDashExplicitObjectWrapper; + } + //_.negate interface LoDashStatic { /**