From f266ea8a346ee8814f83a4a7fd32c13058ccba61 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 6 Nov 2015 03:15:49 +0500 Subject: [PATCH] lodash: signatures of the method _.methodOf have been changed --- lodash/lodash-tests.ts | 46 +++++++++++++++++++++++++++++++++--------- lodash/lodash.d.ts | 27 +++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 876547fd6..146270d4f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -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(object); + result = _.methodOf(object, any); + result = _.methodOf(object, any, any); + result = _.methodOf(object, any, any, any); + + result = _.methodOf(object); + result = _.methodOf(object, any); + result = _.methodOf(object, any, any); + result = _.methodOf(object, any, any, any); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(object).methodOf(); + result = _(object).methodOf(any); + result = _(object).methodOf(any, any); + result = _(object).methodOf(any, any, any); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(object).chain().methodOf(); + result = _(object).chain().methodOf(any); + result = _(object).chain().methodOf(any, any); + result = _(object).chain().methodOf(any, any, any); + } } -var TestMethodOfObject = new TestMethodOf(); -result = (_.methodOf(TestMethodOfObject, 1, 2))('a[0]'); -result = (_.methodOf(TestMethodOfObject, 1, 2))(['a', '0']); -result = (_(TestMethodOfObject).methodOf(1, 2).value())('a[0]'); -result = (_(TestMethodOfObject).methodOf(1, 2).value())(['a', '0']); // _.mixin module TestMixin { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 359cc0fb9..c3e99d4d2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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(object: Object, ...args: any[]): (path: string | any[]) => TResult; + methodOf( + object: TObject, + ...args: any[] + ): (path: StringRepresentable|StringRepresentable[]) => TResult; + + /** + * @see _.methodOf + */ + methodOf( + object: {}, + ...args: any[] + ): (path: StringRepresentable|StringRepresentable[]) => TResult; } interface LoDashImplicitObjectWrapper { /** * @see _.methodOf */ - methodOf(...args: any[]): LoDashImplicitObjectWrapper<(path: string | any[]) => TResult>; + methodOf( + ...args: any[] + ): LoDashImplicitObjectWrapper<(path: StringRepresentable|StringRepresentable[]) => TResult>; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.methodOf + */ + methodOf( + ...args: any[] + ): LoDashExplicitObjectWrapper<(path: StringRepresentable|StringRepresentable[]) => TResult>; } //_.mixin