mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 03:37:53 +08:00
lodash: signatures of the method _.thru changed
This commit is contained in:
@@ -1188,35 +1188,98 @@ module TestTap {
|
||||
}
|
||||
|
||||
// _.thru
|
||||
{
|
||||
let result: number;
|
||||
result = _.thru<number, number>(1, (value: number) => value);
|
||||
result = _.thru<number, number>(1, (value: number) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashImplicitWrapper<number>;
|
||||
result = _(1).thru<number>((value: number) => value);
|
||||
result = _(1).thru<number>((value: number) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashImplicitWrapper<string>;
|
||||
result = _('').thru<string>((value: string) => value);
|
||||
result = _('').thru<string>((value: string) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashImplicitWrapper<boolean>;
|
||||
result = _(true).thru<boolean>((value: boolean) => value);
|
||||
result = _(true).thru<boolean>((value: boolean) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<any>;
|
||||
result = _({}).thru<Object>((value: Object) => value);
|
||||
result = _({}).thru<Object>((value: Object) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<number>;
|
||||
result = _([1, 2, 3]).thru<number>((value: number[]) => value);
|
||||
result = _([1, 2, 3]).thru<number>((value: number[]) => value, any);
|
||||
module TestThru {
|
||||
interface Interceptor<T> {
|
||||
(value: T): T;
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<number>;
|
||||
let result: number;
|
||||
|
||||
result = _.thru<number, number>(1, interceptor);
|
||||
result = _.thru<number, number>(1, interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<number>;
|
||||
let result: _.LoDashImplicitWrapper<number>;
|
||||
|
||||
result = _(1).thru<number>(interceptor);
|
||||
result = _(1).thru<number>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<string>;
|
||||
let result: _.LoDashImplicitWrapper<string>;
|
||||
|
||||
result = _('').thru<string>(interceptor);
|
||||
result = _('').thru<string>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<boolean>;
|
||||
let result: _.LoDashImplicitWrapper<boolean>;
|
||||
|
||||
result = _(true).thru<boolean>(interceptor);
|
||||
result = _(true).thru<boolean>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<{a: string}>;
|
||||
let result: _.LoDashImplicitObjectWrapper<{a: string}>;
|
||||
|
||||
result = _({a: ''}).thru<{a: string}>(interceptor);
|
||||
result = _({a: ''}).thru<{a: string}>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<number[]>;
|
||||
let result: _.LoDashImplicitArrayWrapper<number>;
|
||||
|
||||
result = _([1, 2, 3]).thru<number>(interceptor);
|
||||
result = _([1, 2, 3]).thru<number>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<number>;
|
||||
let result: _.LoDashExplicitWrapper<number>;
|
||||
|
||||
result = _(1).chain().thru<number>(interceptor);
|
||||
result = _(1).chain().thru<number>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<string>;
|
||||
let result: _.LoDashExplicitWrapper<string>;
|
||||
|
||||
result = _('').chain().thru<string>(interceptor);
|
||||
result = _('').chain().thru<string>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<boolean>;
|
||||
let result: _.LoDashExplicitWrapper<boolean>;
|
||||
|
||||
result = _(true).chain().thru<boolean>(interceptor);
|
||||
result = _(true).chain().thru<boolean>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<{a: string}>;
|
||||
let result: _.LoDashExplicitObjectWrapper<{a: string}>;
|
||||
|
||||
result = _({a: ''}).chain().thru<{a: string}>(interceptor);
|
||||
result = _({a: ''}).chain().thru<{a: string}>(interceptor, any);
|
||||
}
|
||||
|
||||
{
|
||||
let interceptor: Interceptor<number[]>;
|
||||
let result: _.LoDashExplicitArrayWrapper<number>;
|
||||
|
||||
result = _([1, 2, 3]).chain().thru<number>(interceptor);
|
||||
result = _([1, 2, 3]).chain().thru<number>(interceptor, any);
|
||||
}
|
||||
}
|
||||
|
||||
// _.prototype.commit
|
||||
|
||||
48
lodash/lodash.d.ts
vendored
48
lodash/lodash.d.ts
vendored
@@ -2377,6 +2377,7 @@ declare module _ {
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like _.tap except that it returns the result of interceptor.
|
||||
*
|
||||
* @param value The value to provide to interceptor.
|
||||
* @param interceptor The function to invoke.
|
||||
* @param thisArg The this binding of interceptor.
|
||||
@@ -2385,7 +2386,8 @@ declare module _ {
|
||||
thru<T, TResult>(
|
||||
value: T,
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): TResult;
|
||||
thisArg?: any
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapperBase<T, TWrapper> {
|
||||
@@ -2413,7 +2415,7 @@ declare module _ {
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends Object>(
|
||||
thru<TResult extends {}>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): LoDashImplicitObjectWrapper<TResult>;
|
||||
|
||||
@@ -2425,6 +2427,48 @@ declare module _ {
|
||||
thisArg?: any): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapperBase<T, TWrapper> {
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends number>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends string>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends boolean>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends {}>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult>(
|
||||
interceptor: (value: T) => TResult[],
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
// _.prototype.commit
|
||||
interface LoDashImplicitWrapperBase<T, TWrapper> {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user