I'm trying to loop through an object which holds a number of properties and the value is always an array of numbers. When I try to run the code below I get the error:
property 'length' does not exist on type 'unknown'
When using Typescrip how do I assign a types when the object key/value pair is destructured in this way?
Thanks
for (const [key, value] of Object.entries(object)) {
console.log(value.length)
}
object/where does it come from? Ideally it would have a type that would encode that knowledge, so you don’t have to do anything on the loop side, but the best way to do that depends on the situation.