Disallow Infinity, -Infinity and NaN as an enum key name#56161
Disallow Infinity, -Infinity and NaN as an enum key name#56161sandersn merged 1 commit intomicrosoft:mainfrom
Infinity, -Infinity and NaN as an enum key name#56161Conversation
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. |
|
@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. |