diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6e70627ec..f6a765b0a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3974,25 +3974,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 877d2e238..0e03c33ac 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7664,6 +7664,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. @@ -7695,6 +7696,18 @@ declare module _ { modArgs(transforms: Function[]): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.modArgs + */ + modArgs(...transforms: Function[]): LoDashExplicitObjectWrapper; + + /** + * @see _.modArgs + */ + modArgs(transforms: Function[]): LoDashExplicitObjectWrapper; + } + //_.negate interface LoDashStatic { /**