I am attempting to change the values of an object, which consist of arrays with numbers as keys, to their respective array lengths.
However, I received a type error that says 'Element implicity has any type because a string element cannot be used to index an object.' I am confused why it is assuming the key is a string when it should be a number.
The code snippet in question is:
const agentOccupancy = Object.entries(agentOccupiedServicesAndQueues).reduce(
(obj, [key, value]) => {
obj[key] = value.length;
return obj;
},
{},
);