Typescript bug or am I stupid?
How can pi_latest_charge within the findIndex function be possibly Null? While two lines above, the assignment to x is valid and not possibly null.
ps: already restarted lint and typescript server.
3 Replies
That null check is outside the function, If one of the possible values of latest_charge is null then when the function inside
findindex
is eventually called later, latest_charge might be null. I assume that might be the logic behind the error.Yes, it must be a scoping thing. However, I'm not using findIndex on latest_charge, but on disputes, so pi.latest_charge doesn't change while looking up my disputes.
Yes, it's scoping and garbage collection thing, you need to recheck the pi.latest_charge inside the findIndex()