-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Any number can be assigned to enum member type #22311
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
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. |
Yes, I expected member type is |
So we'd allow e.g. |
The problem here is that Given the back compat constraints and unlikelihood of finding a bug in userland, keeping the current behavior seems like the best choice of action. |
Search Terms:
enum assign number
Code
Expected behavior:
2 errors: when assigning number literal and wrong enum member.
Actual behavior:
Typescript allows assigning any number to specific member type.
Playground Link:
http://bit.ly/2CZsUrK
The text was updated successfully, but these errors were encountered: