-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Mixed-valued literal enums assignability issue #18082
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
By the way, looks like typechecking for numeric items in such mixed enums doesn't work at all |
This one seems duplicate of #16851. |
The numeric values allowing numbers is there to support bit flags. it is a common use case of enums, and changing that would be a massive break. see similar discussion in #17734. The string values behave as i would expect. enums are "tagged" versions of the string literals. the enum member type is assignable to the string literal type but not vice versa, other wise rename operations are not guaranteed to work. |
@mhegazy Thanks a lot for the explanation. |
TypeScript Version: 2.6 (just checked out)
Code
Expected behavior:
In both cases assignability should work the same way.
Actual behavior:
Assignability passes with numeric literal enum values, but doesn't pass with string literal enum values
The text was updated successfully, but these errors were encountered: