mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Merge pull request #6411 from chrootsu/lodash-method
lodash: signatures of the method _.method changed
This commit is contained in:
+83
-8
@@ -4095,16 +4095,91 @@ module TestMatches {
|
||||
}
|
||||
|
||||
// _.method
|
||||
class TestMethod {
|
||||
a = {
|
||||
b: (a1: number, a2: number) => a1 + a2
|
||||
module TestMethod {
|
||||
{
|
||||
let result: (object: any) => {a: string};
|
||||
|
||||
result = _.method<{a: string}>('a.0');
|
||||
result = _.method<{a: string}>('a.0', any);
|
||||
result = _.method<{a: string}>('a.0', any, any);
|
||||
result = _.method<{a: string}>('a.0', any, any, any);
|
||||
|
||||
result = _.method<{a: string}>(['a', 0]);
|
||||
result = _.method<{a: string}>(['a', 0], any);
|
||||
result = _.method<{a: string}>(['a', 0], any, any);
|
||||
result = _.method<{a: string}>(['a', 0], any, any, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: (object: {a: string}) => {b: string};
|
||||
|
||||
result = _.method<{a: string}, {b: string}>('a.0');
|
||||
result = _.method<{a: string}, {b: string}>('a.0', any);
|
||||
result = _.method<{a: string}, {b: string}>('a.0', any, any);
|
||||
result = _.method<{a: string}, {b: string}>('a.0', any, any, any);
|
||||
|
||||
result = _.method<{a: string}, {b: string}>(['a', 0]);
|
||||
result = _.method<{a: string}, {b: string}>(['a', 0], any);
|
||||
result = _.method<{a: string}, {b: string}>(['a', 0], any, any);
|
||||
result = _.method<{a: string}, {b: string}>(['a', 0], any, any, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<(object: any) => {a: string}>;
|
||||
|
||||
result = _('a.0').method<{a: string}>();
|
||||
result = _('a.0').method<{a: string}>(any);
|
||||
result = _('a.0').method<{a: string}>(any, any);
|
||||
result = _('a.0').method<{a: string}>(any, any, any);
|
||||
|
||||
result = _(['a', 0]).method<{a: string}>();
|
||||
result = _(['a', 0]).method<{a: string}>(any);
|
||||
result = _(['a', 0]).method<{a: string}>(any, any);
|
||||
result = _(['a', 0]).method<{a: string}>(any, any, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<(object: {a: string}) => {b: string}>;
|
||||
|
||||
result = _('a.0').method<{a: string}, {b: string}>();
|
||||
result = _('a.0').method<{a: string}, {b: string}>(any);
|
||||
result = _('a.0').method<{a: string}, {b: string}>(any, any);
|
||||
result = _('a.0').method<{a: string}, {b: string}>(any, any, any);
|
||||
|
||||
result = _(['a', 0]).method<{a: string}, {b: string}>();
|
||||
result = _(['a', 0]).method<{a: string}, {b: string}>(any);
|
||||
result = _(['a', 0]).method<{a: string}, {b: string}>(any, any);
|
||||
result = _(['a', 0]).method<{a: string}, {b: string}>(any, any, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<(object: any) => {a: string}>;
|
||||
|
||||
result = _('a.0').chain().method<{a: string}>();
|
||||
result = _('a.0').chain().method<{a: string}>(any);
|
||||
result = _('a.0').chain().method<{a: string}>(any, any);
|
||||
result = _('a.0').chain().method<{a: string}>(any, any, any);
|
||||
|
||||
result = _(['a', 0]).chain().method<{a: string}>();
|
||||
result = _(['a', 0]).chain().method<{a: string}>(any);
|
||||
result = _(['a', 0]).chain().method<{a: string}>(any, any);
|
||||
result = _(['a', 0]).chain().method<{a: string}>(any, any, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<(object: {a: string}) => {b: string}>;
|
||||
|
||||
result = _('a.0').chain().method<{a: string}, {b: string}>();
|
||||
result = _('a.0').chain().method<{a: string}, {b: string}>(any);
|
||||
result = _('a.0').chain().method<{a: string}, {b: string}>(any, any);
|
||||
result = _('a.0').chain().method<{a: string}, {b: string}>(any, any, any);
|
||||
|
||||
result = _(['a', 0]).chain().method<{a: string}, {b: string}>();
|
||||
result = _(['a', 0]).chain().method<{a: string}, {b: string}>(any);
|
||||
result = _(['a', 0]).chain().method<{a: string}, {b: string}>(any, any);
|
||||
result = _(['a', 0]).chain().method<{a: string}, {b: string}>(any, any, any);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
// _.methodOf
|
||||
class TestMethodOf {
|
||||
|
||||
Vendored
+37
-6
@@ -9751,40 +9751,71 @@ declare module _ {
|
||||
/**
|
||||
* 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;
|
||||
method<TObject, TResult>(
|
||||
path: string|StringRepresentable[],
|
||||
...args: any[]
|
||||
): (object: TObject) => TResult;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(path: any[], ...args: any[]): (object: any) => TResult;
|
||||
method<TResult>(
|
||||
path: string|StringRepresentable[],
|
||||
...args: any[]
|
||||
): (object: any) => TResult;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashImplicitWrapper<(object: any) => TResult>;
|
||||
method<TObject, TResult>(...args: any[]): LoDashImplicitObjectWrapper<(object: TObject) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashImplicitWrapper<(object: any) => TResult>;
|
||||
method<TResult>(...args: any[]): LoDashImplicitObjectWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashImplicitWrapper<(object: any) => TResult>;
|
||||
method<TObject, TResult>(...args: any[]): LoDashImplicitObjectWrapper<(object: TObject) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashImplicitWrapper<(object: any) => TResult>;
|
||||
method<TResult>(...args: any[]): LoDashImplicitObjectWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TObject, TResult>(...args: any[]): LoDashExplicitObjectWrapper<(object: TObject) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashExplicitObjectWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TObject, TResult>(...args: any[]): LoDashExplicitObjectWrapper<(object: TObject) => TResult>;
|
||||
|
||||
/**
|
||||
* @see _.method
|
||||
*/
|
||||
method<TResult>(...args: any[]): LoDashExplicitObjectWrapper<(object: any) => TResult>;
|
||||
}
|
||||
|
||||
//_.methodOf
|
||||
|
||||
Reference in New Issue
Block a user