I am converting a JS file to TS, in my react native project but have stumbled accross this issue that I can't resolve where the value['flag']
is showing the following error,'value' is of type 'unknown'.ts(18046). Any idea on how to solve this will be much appreciated.
The code block is the following:
for (const [key, value] of Object.entries(orderedCities)) { if ( key.startsWith(userInput.toLowerCase()) && userInput != ''&& value !== typeof undefined ) { const inputObject = {city: '', flag: ''}; inputObject.city = key; inputObject.flag = value['flag']; creationArray.push(inputObject); setElementArray(creationArray); } }
I tried declaring a type in the const [key, value] but this triggers a different error, I added the value !== typeof undefined
but this has not changed the error showen.