I am using typescript in a React project and iterating through an array of objects to return components.
I am getting the expected result in the application with no errors in the console, but in VSCode I am getting this error: Property 'amount' does not exist on type 'object'.
For every property that I am referencing in the map.
Here is the code snippet:
{recentHistory.map((item) => {
if (item.type === 'ADD') {
return <AddItem amount={item.amount} memo={item.memo} />
} else if (item.type === 'SUBTRACT') {
return <SubtractItem amount={item.amount} memo={item.memo} />
}
})}
And a screenshot in VSCode.
Again this is producing the expected output and works great, VSCode is just throwing these warnings.