I am new to TypeScript. I am trying to run a similar scenario but it is giving two errors. I don't know what I am missing here. Can anyone please help me to fix this issue?
interface Foo {
[key: string]: number
};
interface Bar {
[key: string]: { positive: number, negative: number }
}
// const obj: Foo | Bar = {
// usa: { positive: 5, negative: 3 },
// uk: { positive: 4, negative: 1 },
// fr: { positive: 8, negative: 2 },
// }
const obj: Foo | Bar = {
usa: 5,
uk: 3,
fr: 2,
}
Object.keys(obj).map(key => {
const val = 'positive' in obj[key] ? obj[key].positive : obj[key];
alert(val);
})
The two errors I am getting are:

