When examining the code snippet below, Typescript initially infers a type string for the inner element type of the values array. However, it subsequently raises an error indicating that string does not have the property "selected".
let item = { values: [{selected: "123"}]}
for (let foobar in item.values) {
if (foobar.selected === '123') {
console.log('found');
}
}
https://i.sstatic.net/CSuHR.png
Upon testing this example in the typescript playground, the aforementioned error is triggered: playground link