Skip to content
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

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

magic-akari
Copy link
Contributor

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Oct 20, 2023
@jakebailey
Copy link
Member

@typescript-bot test top200
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2023

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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at 71e0db6. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2023

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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2023

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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2023

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/158287/artifacts?artifactName=tgz&fileId=1C5C846517B607217AB45065CB8E2CCDCF7096C077DAD97509D5CAC7C7684CCE02&fileName=/typescript-5.3.0-insiders.20231020.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.3.0-pr-56161-5".;

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/56161/merge:

There were infrastructure failures potentially unrelated to your change:

  • 3 instances of "Package install failed"
  • 1 instance of "Unknown failure"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56161/merge:

Everything looks good!

@sandersn sandersn self-assigned this Nov 2, 2023
@sandersn sandersn self-requested a review November 2, 2023 21:37
@jakebailey
Copy link
Member

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?

@sandersn
Copy link
Member

sandersn commented Dec 4, 2023

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.

@jakebailey
Copy link
Member

My impression was that this PR was good, as they're not good enum names, but that the recent infinity chat was about the whole 1e999 thing allowing a half-functional backdoor into gaining an infinity type, which we banned but then backed out and decided that we were instead going to look into introducing those literal types into the type system instead.

@sandersn
Copy link
Member

sandersn commented Dec 6, 2023

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.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

@sandersn sandersn merged commit ecc1024 into microsoft:main Dec 6, 2023
19 checks passed
c0sta pushed a commit to c0sta/TypeScript that referenced this pull request Dec 20, 2023
@JoostK
Copy link
Contributor

JoostK commented Feb 13, 2024

@DanielRosenwasser This change is missing from the breaking changes section in the the blog post, perhaps it can be included.

@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Feb 13, 2024
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Feb 22, 2024

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.

@magic-akari magic-akari deleted the fix/issue-48956 branch February 22, 2024 03:06
XeroAlpha added a commit to XeroAlpha/sapi-typedoc that referenced this pull request Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Enum with special numbers overwrites own value
6 participants