diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 877364ef0..521e0e11c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1385,6 +1385,18 @@ result = <() => boolean>_(true).constant(); result = <() => any[]>_(['a']).constant(); result = <() => {}>_({}).constant<{}>(); +// _.method +class TestMethod { + a = { + b: (a1: number, a2: number) => a1 + a2 + } +} +var TestMethodObject = new TestMethod(); +result = (_.method('a.b', 1, 2))(TestMethodObject); +result = (_.method(['a', 'b'], 1, 2))(TestMethodObject); +result = (_('a.b').method(1, 2).value())(TestMethodObject); +result = (_(['a', 'b']).method(1, 2).value())(TestMethodObject); + result = _.VERSION; result = <_.Support>_.support; result = <_.TemplateSettings>_.templateSettings; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7bbb65a54..45ca76540 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6826,6 +6826,47 @@ declare module _ { identity(value?: T): T; } + //_.method + interface LoDashStatic { + /** + * Creates a function that invokes the method at path on a given object. Any additional arguments are provided + * to the invoked method. + * @param path The path of the method to invoke. + * @param args The arguments to invoke the method with. + * @return Returns the new function. + */ + method(path: string, ...args: any[]): (object: any) => TResult; + + /** + * @see _.method + */ + method(path: any[], ...args: any[]): (object: any) => TResult; + } + + interface LoDashWrapper { + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + } + + interface LoDashArrayWrapper { + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + } + //_.mixin interface LoDashStatic { /**