From ccb674adc72864b791b0b4f12b4e522733774c6f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 10:00:58 +0200 Subject: [PATCH 1/5] Changed types for chained functions and added tests --- types/underscore/index.d.ts | 6 +++--- types/underscore/underscore-tests.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..db45cf606b 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -5692,7 +5692,7 @@ declare module _ { * Wrapped type `object`. * @see _.values **/ - values(): _Chain; + values(): _Chain; /** * Wrapped type `object`. @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..220bbcb0ef 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,20 @@ function chain_tests() { .keys() // return ['foo', 'bar'] : string[] .pairs() // return [['foo', '0'], ['bar', '1']] : string[][] .value(); + + interface IYears { + 2016: number; + 2017: number; + } + + let yearObject: IYears = {2016: 1, 2017: 2}; + let valuePerYear: number[] = _.chain(yearObject) + .values() + .value() + + let keyValuePerYear: (string|number)[][] = _.chain(yearObject) + .pairs() + .value() } var obj: { [k: string] : number } = { From 017ffb7238ce29d3a2bf9d066080c8dc18c4ab8f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:19:40 +0200 Subject: [PATCH 2/5] Updated types for pairs --- types/underscore/index.d.ts | 4 ++-- types/underscore/underscore-tests.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index db45cf606b..94ed13d099 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -3631,7 +3631,7 @@ declare module _ { * @param object Convert this object to a list of [key, value] pairs. * @return List of [key, value] pairs on `object`. **/ - pairs(object: any): any[][]; + pairs(object: any): [string, any][]; /** * Returns a copy of the object where the keys have become the values and the values the keys. @@ -4738,7 +4738,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): any[][]; + pairs(): [string, any][]; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 220bbcb0ef..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -537,10 +537,6 @@ function chain_tests() { let valuePerYear: number[] = _.chain(yearObject) .values() .value() - - let keyValuePerYear: (string|number)[][] = _.chain(yearObject) - .pairs() - .value() } var obj: { [k: string] : number } = { From 2d9422f0cbfab797ad64f786ee33627af90d7fc0 Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:22:38 +0200 Subject: [PATCH 3/5] Added my name --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 94ed13d099..27346d414d 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; From 7146aa04998d5453240fc273caa584cdf4e87d7c Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:29:05 +0200 Subject: [PATCH 4/5] Added space after comment which was removed by my editor --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 27346d414d..95ff48eddc 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } From 89eff5086697c1a254da6e0fe63aa46f8d61b543 Mon Sep 17 00:00:00 2001 From: Confusus Date: Wed, 8 Aug 2018 09:14:15 +0200 Subject: [PATCH 5/5] Changed pairs of chain from any to [string, any] --- types/underscore/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 95ff48eddc..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`.