mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
add test to reproduce issue
This commit is contained in:
@@ -664,6 +664,36 @@ interface Obj {
|
||||
byGrade(students);
|
||||
};
|
||||
|
||||
() => {
|
||||
interface MyObject {
|
||||
id: string;
|
||||
quantity: number;
|
||||
}
|
||||
|
||||
const reduceWithCombinedQuantities = (items: MyObject[]) =>
|
||||
items.reduce<MyObject>(
|
||||
(acc, item) => ({...item, quantity: acc.quantity + item.quantity}),
|
||||
{id: '', quantity: 0},
|
||||
);
|
||||
|
||||
const combineMyObjects = R.pipe(
|
||||
R.groupBy<MyObject>(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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user