Correct way to tell typescript object's index is not undefined when mapping over keys ?

As shown in the example I am mapping over the keys of an object so if I am not wrong the value obtained should never be undefined so how do I tell typescript that without using as <typeof_value_here>.
Is using type casting here with as the correct way to do it or is there a better way to do it ?
2 Replies
Ramazan
Ramazan2y ago
You probably want to use Object.entries here and map over that instead. As to why this particular way of doing it doesn’t work, I can’t say.
KP
KP2y ago
oh didnt know about Object.entries. Thanks :D
Want results from more Discord servers?
Add your server