From f82f720bb3c47859a3f2ff53546ee69ebec3f120 Mon Sep 17 00:00:00 2001 From: Michael Heasell Date: Fri, 15 Feb 2019 11:31:52 +0000 Subject: [PATCH] Fix wrongly-defined return type for _.matches, _.matcher --- types/underscore/index.d.ts | 8 ++++++-- types/underscore/underscore-tests.ts | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 72498e3591..1b89408ab3 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -69,6 +69,10 @@ declare module _ { [index: string]: T; } + interface Predicate { + (value: T): boolean; + } + interface ListIterator { (value: T, index: number, list: List): TResult; } @@ -3782,7 +3786,7 @@ declare module _ { * @param attrs Object with key values pair * @return Predicate function **/ - matches(attrs: T): _.ListIterator; + matches(attrs: T): _.Predicate; /** * 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(attrs: T): _.ListIterator; + matcher(attrs: T): _.Predicate; /** * Returns a function that will itself return the key property of any passed-in object. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 6175c1874b..13bc542b28 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -216,6 +216,8 @@ interface Family { } var isUncleMoe = _.matches({ name: 'moe', relation: 'uncle' }); _.filter([{ name: 'larry', relation: 'father' }, { name: 'moe', relation: 'uncle' }], isUncleMoe); +var uncleMoe: Family = { name: 'moe', relation: 'uncle' }; +isUncleMoe(uncleMoe);