Repository navigation
Breaking change in string enum member type in v3.6 #33403
Description
Activity
I'm on mobile but does
Object.values<string>(Colors)help?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 (
(Object.values(Colors) as string[]).includes(a))!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.
Reacted by AnyhowStepIt's different from a cast because the values of the enum are assignable to string. But you already knew that.
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'll probably be marked intentional. But I'll wait for the official word!
Reacted by Ryan CavanaughRyanCavanaugh commented
on Sep 13, 2019 MemberMore actionsThis is caused by #31687, which is already an identified breaking change
Reacted by AnyhowStep...meaning maybe this is a duplicate of #33200?
Reacted by Ryan Cavanaugh- addedWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
on Sep 13, 2019 Okay, if it was intentional then I think we're all good! Thanks for the quick turn around.
Ryan Cavanaugh (@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?
Reacted by Victor Olivatypescript-bot commented
on Sep 15, 2019 ContributorMore actionsThis issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
- locked as resolved and limited conversation to collaborators
on Oct 21, 2025
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.valuestype 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?