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

fix: Infinity in enums #15774

Merged
merged 1 commit into from Jul 12, 2023
Merged

fix: Infinity in enums #15774

merged 1 commit into from Jul 12, 2023

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Jul 11, 2023

Q                       A
Fixed Issues? Fixes #15768
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass?
Documentation PR Link
Any Dependency Changes?
License MIT

@liuxingbaoyu liuxingbaoyu added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: typescript i: regression labels Jul 11, 2023
StateEnum[StateEnum["pos"] = Infinity] = "pos";
StateEnum[StateEnum["nan"] = NaN] = "nan";
StateEnum[StateEnum["ext"] = 42] = "ext";
StateEnum[StateEnum["ext2"] = 1] = "ext2";
Copy link
Member Author

Choose a reason for hiding this comment

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

This is inconsistent with TS, if we want to align, it is most convenient to add a feature in traverse.

@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54834/

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

@@ -0,0 +1,11 @@
const v = 42;
const v2 = Infinity;
var Infinity = 1; // Known inconsistencies
Copy link
Member

Choose a reason for hiding this comment

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

Note that in scripts this doesn't actually change the value of Infinity. However, there is another case in which it does and TS is not behaving as I would expect: microsoft/TypeScript#54981

@JLHwung JLHwung merged commit b7faa90 into babel:main Jul 12, 2023
57 checks passed
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: TypeScript Enums With Global Properties Like Infinity or NaN Are Transpiled as Members
4 participants