From c3e46db64e69a78f9e5dfbadc22e31dba2a040a0 Mon Sep 17 00:00:00 2001 From: Vincent Jaubert Date: Sun, 16 Oct 2016 17:20:21 +0200 Subject: [PATCH 1/3] 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[]; /** From 0cc6854a1694dcb389a4e6675c0519a828a71418 Mon Sep 17 00:00:00 2001 From: Vincent Jaubert Date: Sun, 16 Oct 2016 17:43:00 +0200 Subject: [PATCH 2/3] [Underscore] Add Iteratee shorthand syntax for some usages of map and uniq --- underscore/underscore.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index ef76d966c4..23a2494516 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -3,8 +3,6 @@ // 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. From 0d21cc33ca2817d53d06f2ec792579a06ab0a848 Mon Sep 17 00:00:00 2001 From: Vincent Jaubert Date: Sun, 16 Oct 2016 17:45:29 +0200 Subject: [PATCH 3/3] [Underscore] Add Iteratee shorthand syntax for some usages of map and uniq --- underscore/underscore.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 23a2494516..8f8e32d370 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -162,7 +162,7 @@ interface UnderscoreStatic { **/ map( object: _.Dictionary, - iterator: _.ObjectIterator , + iterator: _.ObjectIterator, context?: any): TResult[];