lodash: signatures of the method _.restParam have been changed

This commit is contained in:
Ilya Mochalov
2015-11-14 18:38:28 +05:00
parent efd40e67ff
commit 6a5ee5c6e3
2 changed files with 48 additions and 12 deletions
+30 -10
View File
@@ -3927,17 +3927,37 @@ result = <string[]>(_.rearg<TestReargResultFn>(testReargFn, [2, 0, 1]))('b', 'c'
result = <string[]>(_(testReargFn).rearg<TestReargResultFn>(2, 0, 1).value())('b', 'c', 'a');
result = <string[]>(_(testReargFn).rearg<TestReargResultFn>([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<ResultFunc>(func);
result = _.restParam<ResultFunc>(func, 1);
result = _.restParam<ResultFunc, Func>(func);
result = _.restParam<ResultFunc, Func>(func, 1);
}
{
let result: _.LoDashImplicitObjectWrapper<ResultFunc>;
result = _(func).restParam<ResultFunc>();
result = _(func).restParam<ResultFunc>(1);
}
{
let result: _.LoDashExplicitObjectWrapper<ResultFunc>;
result = _(func).chain().restParam<ResultFunc>();
result = _(func).chain().restParam<ResultFunc>(1);
}
}
interface testRestParamResult {
(a: string, b: string, ...c: number[]): string;
}
result = <string>(_.restParam<testRestParamResult, testRestParamFunc>(testRestParamFn, 2))('a', 'b', 1, 2, 3);
result = <string>(_.restParam<testRestParamResult>(testRestParamFn, 2))('a', 'b', 1, 2, 3);
result = <string>(_(testRestParamFn).restParam<testRestParamResult>(2).value())('a', 'b', 1, 2, 3);
//_.spread
var testSpreadFn = (who: string, what: string) => who + ' says ' + what;
+18 -2
View File
@@ -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<TResult extends Function>(func: Function, start?: number): TResult;
restParam<TResult extends Function>(
func: Function,
start?: number
): TResult;
/**
* @see _.restParam
*/
restParam<TResult extends Function, TFunc extends Function>(func: TFunc, start?: number): TResult;
restParam<TResult extends Function, TFunc extends Function>(
func: TFunc,
start?: number
): TResult;
}
interface LoDashImplicitObjectWrapper<T> {
@@ -7821,6 +7830,13 @@ declare module _ {
restParam<TResult extends Function>(start?: number): LoDashImplicitObjectWrapper<TResult>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.restParam
*/
restParam<TResult extends Function>(start?: number): LoDashExplicitObjectWrapper<TResult>;
}
//_.spread
interface LoDashStatic {
/**