diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4c587b57b..a277e6da7 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3927,17 +3927,37 @@ result = (_.rearg(testReargFn, [2, 0, 1]))('b', 'c' result = (_(testReargFn).rearg(2, 0, 1).value())('b', 'c', 'a'); result = (_(testReargFn).rearg([2, 0, 1]).value())('b', 'c', 'a'); -//_.restParam -var testRestParamFn = (a: string, b: string, c: number[]) => a + ' ' + b + ' ' + c.join(' '); -interface testRestParamFunc { - (a: string, b: string, c: number[]): string; +// _.restParam +module TestRestParam { + type Func = (a: string, b: number[]) => boolean; + type ResultFunc = (a: string, ...b: number[]) => boolean; + + let func: Func; + + { + let result: ResultFunc; + + result = _.restParam(func); + result = _.restParam(func, 1); + + result = _.restParam(func); + result = _.restParam(func, 1); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(func).restParam(); + result = _(func).restParam(1); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(func).chain().restParam(); + result = _(func).chain().restParam(1); + } } -interface testRestParamResult { - (a: string, b: string, ...c: number[]): string; -} -result = (_.restParam(testRestParamFn, 2))('a', 'b', 1, 2, 3); -result = (_.restParam(testRestParamFn, 2))('a', 'b', 1, 2, 3); -result = (_(testRestParamFn).restParam(2).value())('a', 'b', 1, 2, 3); //_.spread var testSpreadFn = (who: string, what: string) => who + ' says ' + what; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 98d8bf55d..9b2c80894 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7802,16 +7802,25 @@ declare module _ { /** * Creates a function that invokes func with the this binding of the created function and arguments from start * and beyond provided as an array. + * + * Note: This method is based on the rest parameter. + * * @param func The function to apply a rest parameter to. * @param start The start position of the rest parameter. * @return Returns the new function. */ - restParam(func: Function, start?: number): TResult; + restParam( + func: Function, + start?: number + ): TResult; /** * @see _.restParam */ - restParam(func: TFunc, start?: number): TResult; + restParam( + func: TFunc, + start?: number + ): TResult; } interface LoDashImplicitObjectWrapper { @@ -7821,6 +7830,13 @@ declare module _ { restParam(start?: number): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.restParam + */ + restParam(start?: number): LoDashExplicitObjectWrapper; + } + //_.spread interface LoDashStatic { /**