-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Breaking change in string enum member type in v3.6 #33403
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'm on mobile but does |
@AnyhowStep it does, but IMHO that is roughly equivalent to a cast. I can get my code to work with a cast, so that's not really my concern at the moment. But thank you for offering something that looks a little better than what I was going to do ( My main concern is that it might not be intended, and we might want to consider this a regression and force it back. At least until that design choice can be explicitly made and then note it as part of 3.7's breaking changes. |
It's different from a cast because the values of the enum are assignable to string. But you already knew that.
It'll probably be marked intentional. But I'll wait for the official word! |
This is caused by #31687, which is already an identified breaking change |
...meaning maybe this is a duplicate of #33200? |
Okay, if it was intentional then I think we're all good! Thanks for the quick turn around. @RyanCavanaugh I was under the impression that the Breaking Changes wiki page was meant to be exhaustive, but I don't see the changes in #31687 mentioned there, the release notes, or anywhere else. Is that a mistake? Should I offer an edit to the wiki to update it? |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
In order to check whether a given string is a member of a string Enum, I use the code shown below. There seems to be an unintentional breaking change in v3.6.2 and later - this code compiles just fine in v3.3.x - v3.5.x.
Search Terms: enum, includes, string enum
Code
Expected behavior: Compiles successfully 👍
Actual behavior: Error on L9 (on call site for
includes(...)
)The
Object.values
type definition doesn't change across these versions, and is the following:So it seems that string Enums have begun to match the interface
{ [s: string]: T }
where they didn't before. I can understand why it might, but is this intended?The text was updated successfully, but these errors were encountered: