-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Disallow Infinity
, -Infinity
and NaN
as an enum key name
#56161
Conversation
magic-akari
commented
Oct 20, 2023
- Fixes Enum with special numbers overwrites own value #48956
@typescript-bot test top200 |
Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 71e0db6. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the tarball bundle task on this PR at 71e0db6. You can monitor the build here. |
Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 71e0db6. You can monitor the build here. Update: The results are in! |
Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 71e0db6. You can monitor the build here. Update: The results are in! |
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@jakebailey Here are the results of running the user test suite comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
Hey @jakebailey, the results of running the DT tests are ready. |
@jakebailey Here are the results of running the top-repos suite comparing Everything looks good! |
I can't recall; was banning this actually something we wanted? Can't remember what we said in the design meeting, or maybe we didn't talk about it at all? |
My memory is that we briefly discussed this and said "yes of course you can't do that because of the lookup object", but I could be wrong. We did discuss Infinity types a couple of weeks after your comment, but that's the only mention of Infinity and NaN in the design notes. And then a couple of days after that, we discussed enum assignability. So it sounds like my memory smudged the two discussions together and in fact we never did. I still think this is a good thing to forbid since the emit is bad and it's unlikely to be something people want to write. |
My impression was that this PR was good, as they're not good enum names, but that the recent |
Right, and since enum members introduce values as well as types, I think that we'll still want to ban these names because of their value problems. So...I think it's good to merge? Pretty sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
@DanielRosenwasser This change is missing from the breaking changes section in the the blog post, perhaps it can be included. |
Even if this ends up being the desired behavior - I'm surprised we merged this because the logic was explicitly there, and was added 8ish years ago
Given that there's no linked design meeting notes, in the future let's have a more intentional discussion before merging a change like this. |