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
{{ message }}
Repository navigation
Any number can be assigned to enum member type #22311
Activity
[-]Any number can be assigning to enum member type[/-][+]Any number can be assigned to enum member type[/+]DanielRosenwasser commentedon Mar 3, 2018
I was very close to marking this as a duplicate (mostly with #6131 in mind, but also sort of #8020 - see #8020 (comment)).
The key thing here is that we're working with an individual enum member type, not just an enum type.
rlz commentedon Mar 3, 2018
Yes, I expected member type is
0in this case, so I should be able to assign0but not5.RyanCavanaugh commentedon Apr 16, 2018
So we'd allow e.g.
const x: X.A = 5 + 0but not= 5?RyanCavanaugh commentedon Aug 7, 2018
The problem here is that
Xis just an alias forX.A | X.B, so any argument about assignability toX.Aapplies equally to assignability toX.Given the back compat constraints and unlikelihood of finding a bug in userland, keeping the current behavior seems like the best choice of action.