Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

Typescript ->'value' is of type 'unknown'. in a React Native project

$
0
0

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.


Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>