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
It seems like every branch assigns the variable, but maybe I there's a secret branch I can't see.
Use Cases
I'm forced to add a ! or a default. Neither are really optimal. If type Foo changes later to include a third case, at that point I would like typescript to complain about this error. Effectively I would like to be statically guarded to the Foo type changing.
Checklist
My suggestion meets these guidelines:
This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
@RyanCavanaugh I added fixed labels to the associated issues I posted above --- mainly because one was locked and I could only label it. Just letting you know so you can amend my labels.
Search Terms
used before assigned
switch
Suggestion
The following source returns
Variable 'hi' is used before being assigned.
:It seems like every branch assigns the variable, but maybe I there's a secret branch I can't see.
Use Cases
I'm forced to add a
!
or adefault
. Neither are really optimal. Iftype Foo
changes later to include a third case, at that point I would like typescript to complain about this error. Effectively I would like to be statically guarded to the Foo type changing.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: