mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 04:00:10 +00:00
Fix wrongly-defined return type for _.matches, _.matcher
This commit is contained in:
8
types/underscore/index.d.ts
vendored
8
types/underscore/index.d.ts
vendored
@@ -69,6 +69,10 @@ declare module _ {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
interface Predicate<T> {
|
||||
(value: T): boolean;
|
||||
}
|
||||
|
||||
interface ListIterator<T, TResult> {
|
||||
(value: T, index: number, list: List<T>): TResult;
|
||||
}
|
||||
@@ -3782,7 +3786,7 @@ declare module _ {
|
||||
* @param attrs Object with key values pair
|
||||
* @return Predicate function
|
||||
**/
|
||||
matches<T>(attrs: T): _.ListIterator<T, boolean>;
|
||||
matches<T>(attrs: T): _.Predicate<T>;
|
||||
|
||||
/**
|
||||
* Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs.
|
||||
@@ -3790,7 +3794,7 @@ declare module _ {
|
||||
* @param attrs Object with key values pair
|
||||
* @return Predicate function
|
||||
**/
|
||||
matcher<T>(attrs: T): _.ListIterator<T, boolean>;
|
||||
matcher<T>(attrs: T): _.Predicate<T>;
|
||||
|
||||
/**
|
||||
* Returns a function that will itself return the key property of any passed-in object.
|
||||
|
||||
@@ -216,6 +216,8 @@ interface Family {
|
||||
}
|
||||
var isUncleMoe = _.matches<Family>({ name: 'moe', relation: 'uncle' });
|
||||
_.filter([{ name: 'larry', relation: 'father' }, { name: 'moe', relation: 'uncle' }], isUncleMoe);
|
||||
var uncleMoe: Family = { name: 'moe', relation: 'uncle' };
|
||||
isUncleMoe(uncleMoe);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user