What's the right way to solve this?
Typescript error:
updatedLoraStack[index]
might be undefined, but we check it's not in the line before
If I set updatedLoraStack[index]
as a variable, check if its undefined and then set it, it won't update the original array5 Replies
unfortunately ts doesn't narrow array types like this properly
Solution
just use
!
to tell ts you're use it's therethx
Extract it to a variable and check the variable as another option
That lets you skip adding a !
yea, but when I set that variable it wont affect the 1st array
for example^
and what i would need is
[1, 5, 3]
, but q = 5
only affects that original q
value, and not the b
array