[Vuejs]-'Object is of type unknown' inside map function in VueJS

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),
}))

Leave a comment