mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-26 11:12:19 +08:00
Merge pull request #5102 from chrootsu/lodash-method
lodash: added _.method() method
This commit is contained in:
@@ -1385,6 +1385,18 @@ result = <() => boolean>_(true).constant<boolean>();
|
||||
result = <() => any[]>_(['a']).constant<any[]>();
|
||||
result = <() => {}>_({}).constant<{}>();
|
||||
|
||||
// _.method
|
||||
class TestMethod {
|
||||
a = {
|
||||
b: (a1: number, a2: number) => a1 + a2
|
||||
}
|
||||
}
|
||||
var TestMethodObject = new TestMethod();
|
||||
result = <number>(_.method<number>('a.b', 1, 2))(TestMethodObject);
|
||||
result = <number>(_.method<number>(['a', 'b'], 1, 2))(TestMethodObject);
|
||||
result = <number>(_('a.b').method<number>(1, 2).value())(TestMethodObject);
|
||||
result = <number>(_(['a', 'b']).method<number>(1, 2).value())(TestMethodObject);
|
||||
|
||||
result = <string>_.VERSION;
|
||||
result = <_.Support>_.support;
|
||||
result = <_.TemplateSettings>_.templateSettings;
|
||||
|
||||
Vendored
+41
@@ -6826,6 +6826,47 @@ declare module _ {
|
||||
identity<T>(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<TResult>(path: string, ...args: any[]): (object: any) => TResult;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(path: any[], ...args: any[]): (object: any) => TResult;
|
||||
}
|
||||
|
||||
interface LoDashWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
//_.mixin
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user