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

This commit is contained in:
Ilya Mochalov
2015-11-06 03:16:49 +05:00
parent 35989a3ab4
commit f266ea8a34
2 changed files with 62 additions and 11 deletions
+37 -9
View File
@@ -5673,16 +5673,44 @@ module TestMethod {
}
// _.methodOf
class TestMethodOf {
a = [
(a1: number, a2: number) => a1 + a2
];
module TestMethodOf {
type SampleObject = {a: {b: () => TResult}[]};
type ResultFn = (path: _.StringRepresentable|_.StringRepresentable[]) => TResult;
let object: SampleObject;
{
let result: ResultFn;
result = _.methodOf<SampleObject, TResult>(object);
result = _.methodOf<SampleObject, TResult>(object, any);
result = _.methodOf<SampleObject, TResult>(object, any, any);
result = _.methodOf<SampleObject, TResult>(object, any, any, any);
result = _.methodOf<TResult>(object);
result = _.methodOf<TResult>(object, any);
result = _.methodOf<TResult>(object, any, any);
result = _.methodOf<TResult>(object, any, any, any);
}
{
let result: _.LoDashImplicitObjectWrapper<ResultFn>;
result = _(object).methodOf<TResult>();
result = _(object).methodOf<TResult>(any);
result = _(object).methodOf<TResult>(any, any);
result = _(object).methodOf<TResult>(any, any, any);
}
{
let result: _.LoDashExplicitObjectWrapper<ResultFn>;
result = _(object).chain().methodOf<TResult>();
result = _(object).chain().methodOf<TResult>(any);
result = _(object).chain().methodOf<TResult>(any, any);
result = _(object).chain().methodOf<TResult>(any, any, any);
}
}
var TestMethodOfObject = new TestMethodOf();
result = <number>(_.methodOf<number>(TestMethodOfObject, 1, 2))('a[0]');
result = <number>(_.methodOf<number>(TestMethodOfObject, 1, 2))(['a', '0']);
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())('a[0]');
result = <number>(_(TestMethodOfObject).methodOf<number>(1, 2).value())(['a', '0']);
// _.mixin
module TestMixin {
+25 -2
View File
@@ -11276,18 +11276,41 @@ declare module _ {
/**
* The opposite of _.method; this method creates a function that invokes the method at a given path on object.
* Any additional arguments are provided to the invoked method.
*
* @param object The object to query.
* @param args The arguments to invoke the method with.
* @return Returns the new function.
*/
methodOf<TResult>(object: Object, ...args: any[]): (path: string | any[]) => TResult;
methodOf<TObject extends {}, TResult>(
object: TObject,
...args: any[]
): (path: StringRepresentable|StringRepresentable[]) => TResult;
/**
* @see _.methodOf
*/
methodOf<TResult>(
object: {},
...args: any[]
): (path: StringRepresentable|StringRepresentable[]) => TResult;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.methodOf
*/
methodOf<TResult>(...args: any[]): LoDashImplicitObjectWrapper<(path: string | any[]) => TResult>;
methodOf<TResult>(
...args: any[]
): LoDashImplicitObjectWrapper<(path: StringRepresentable|StringRepresentable[]) => TResult>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.methodOf
*/
methodOf<TResult>(
...args: any[]
): LoDashExplicitObjectWrapper<(path: StringRepresentable|StringRepresentable[]) => TResult>;
}
//_.mixin