Error of object possibly undefined

Hey i'm getting error "Object is possibly undefined even tho I'm checking him before. I can't figure it out...
5 Replies
Tom
Tom2y ago
not sure what the problem is but you may want to use ?? which will be shorter and not have the syntax error but i dont know whats going on specifically
ja_iy
ja_iy2y ago
Error might be arising from typescript not knowing if fieldErrors[item] exists hence possibly being undefined, thus fieldErrors[item][0] could possibly evaluate to undefined[0] nevermind that shouldn't be the case because of the ? check srry
__fallenreaper
youre assigning a value to possibly be undefined, so you should consider a base value?
Paweł
PawełOP2y ago
But I assign empty string if fieldErrors[item] is undefined not sure if that's what you meant
__fallenreaper
Looking to create a quick sample in VSC rq Can you send me a code snippet or provide a github where this is a problem to better understand outlier constraints?
Want results from more Discord servers?
Add your server