You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have weird situation. The code below seems pretty simple to infer that myVar cannot be null or undefined, but I am still getting this error (TS2532). Is ts compiler not capable to do this yet?
Please ignore render and console being underlined red, those are tslint errors.
Thanks.
P.S. Sorry if this question was asked before, I look through all issues related to this error code.
The text was updated successfully, but these errors were encountered:
val-o
changed the title
TS2532 when class member to local variable
TS2532 when class member assigned to local variable
Aug 23, 2018
I don't recall the prior issues, but AFAIK typescript does not narrow based on the value of other variables. If you used
if(this.myVar){ ... }
you wouldn't get the error. I'm assuming this is a simplified repro, as you could always just remove the |null from the type declaration (after all, myVar is readonly).
TS version: 3.0.1
Hi, I have weird situation. The code below seems pretty simple to infer that
myVar
cannot be null or undefined, but I am still getting this error (TS2532). Is ts compiler not capable to do this yet?Please ignore render and console being underlined red, those are tslint errors.
Thanks.
P.S. Sorry if this question was asked before, I look through all issues related to this error code.
The text was updated successfully, but these errors were encountered: