TS Error:
Type '(string | undefined)[]' cannot be used as an index type.ts(2538)
Code:
Object.values(payload.reduce((acc, obj) => {
let key = obj.values.map(i => i.object_id);
if (!acc[key]) {
acc[key] = []
}
acc[key].push(obj)
return acc
}, {}))
Works fine in the javascript code. Why?