0๐
โ
I ended up breaking this out into separate functions and that resolved the typing issue:
const groupByDate = (values) => {
return Object.values(
values.reduce((r, { x, y }) => {
r[x] ?? (r[x] = { x, y: 0 })
r[x].y += y
return r
}, {})
)
}
return Object.entries(groupedDataByProduct).map(([name, data1]) => ({
name,
data: groupByDate(data1),
}))
Source:stackexchange.com