From f84d7c79522f7127280fc9e482009b3c112da1c7 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Fri, 2 Mar 2018 23:25:48 -0500 Subject: [PATCH 1/3] add test to reproduce issue --- types/ramda/ramda-tests.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index c32ab72028..4b5abfe19f 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -664,6 +664,36 @@ interface Obj { byGrade(students); }; +() => { + interface MyObject { + id: string; + quantity: number; + } + + const reduceWithCombinedQuantities = (items: MyObject[]) => + items.reduce( + (acc, item) => ({...item, quantity: acc.quantity + item.quantity}), + {id: '', quantity: 0}, + ); + + const combineMyObjects = R.pipe( + R.groupBy(s => s.id), + R.values, + R.map(reduceWithCombinedQuantities), + ); + + const combined = combineMyObjects([ + {id: 'foo', quantity: 4}, + {id: 'bar', quantity: 3}, + {id: 'foo', quantity: 2}, + ]); + + return { + id: combined[0].id, + quantity: combined[0].quantity + }; +}; + () => { R.groupWith(R.equals)([0, 1, 1, 2, 3, 5, 8, 13, 21]); From 5455a50acd67587bbccf12233386a8ee9f84de72 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Fri, 2 Mar 2018 23:30:06 -0500 Subject: [PATCH 2/3] remove extra generic type on curried function --- types/ramda/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 081a62cbd7..fcd3b2b06f 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -679,7 +679,7 @@ declare namespace R { * on each element, and grouping the results according to values returned. */ groupBy(fn: (a: T) => string, list: ReadonlyArray): { [index: string]: T[] }; - groupBy(fn: (a: T) => string): (list: ReadonlyArray) => { [index: string]: T[] }; + groupBy(fn: (a: T) => string): (list: ReadonlyArray) => { [index: string]: T[] }; /** * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function From 99ccbdcdfc6b79d7a9388332ac7b570debae0c3e Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Fri, 2 Mar 2018 23:48:54 -0500 Subject: [PATCH 3/3] bump TypeScript version to 2.6 in header --- types/ramda/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index fcd3b2b06f..9004ec7651 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -16,7 +16,7 @@ // Nikita Moshensky // Ethan Resnick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.6 declare let R: R.Static;