From c3e46db64e69a78f9e5dfbadc22e31dba2a040a0 Mon Sep 17 00:00:00 2001 From: Vincent Jaubert Date: Sun, 16 Oct 2016 17:20:21 +0200 Subject: [PATCH] added iteratee shorthand syntax for some usages of map and uniq --- underscore/underscore.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index d8d08a3b75..ef76d966c4 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -3,6 +3,8 @@ // Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import IterateeMatcherShorthand = _.IterateeMatcherShorthand; +import IterateePropertyShorthand = _.IterateePropertyShorthand; declare module _ { /** * underscore.js _.throttle options. @@ -67,6 +69,10 @@ declare module _ { (element: T, key: string, list: Dictionary): TResult; } + type IterateePropertyShorthand = string | number; + + type IterateeMatcherShorthand = Dictionary; + interface MemoIterator { (prev: TResult, curr: T, index: number, list: List): TResult; } @@ -146,7 +152,7 @@ interface UnderscoreStatic { **/ map( list: _.List, - iterator: _.ListIterator, + iterator: _.ListIterator | _.IterateePropertyShorthand | _.IterateeMatcherShorthand, context?: any): TResult[]; /** @@ -158,15 +164,16 @@ interface UnderscoreStatic { **/ map( object: _.Dictionary, - iterator: _.ObjectIterator, + iterator: _.ObjectIterator , context?: any): TResult[]; + /** * @see _.map **/ collect( list: _.List, - iterator: _.ListIterator, + iterator: _.ListIterator | _.IterateePropertyShorthand | _.IterateeMatcherShorthand, context?: any): TResult[]; /** @@ -900,7 +907,7 @@ interface UnderscoreStatic { uniq( array: _.List, isSorted?: boolean, - iterator?: _.ListIterator, + iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): T[]; /** @@ -916,7 +923,7 @@ interface UnderscoreStatic { **/ unique( array: _.List, - iterator?: _.ListIterator, + iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): T[]; /**