-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Assignability between number and enum type #10738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Regression from 1.8 behavior |
Also for added mystery, changing the enum to single element |
I think this is caused by the switch to enums-as-unions, which would explain why the single-member enum doesn't have the bug. |
Also |
|
Fix is up at #10784 |
TypeScript Version: nightly (2.0.0-dev.201xxxxx)
Code
Expected behavior:
Either disallow assigning
number
toE
, reasonable if one considersE
equivalent to0 | 1
. Or allow the assignment ofnumber
toE | boolean
.Actual behavior:
let z: E|boolean = n; // ERROR(9,5): : Type 'number' is not assignable to type 'boolean | E'.
The text was updated successfully, but these errors were encountered: