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
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 specificallyError 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
youre assigning a value to possibly be undefined, so you should consider a base value?
But I assign empty string if fieldErrors[item] is undefined not sure if that's what you meant
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?