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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: References to merging enum member is lost #16133

Closed
1 task
magic-akari opened this issue Nov 28, 2023 · 1 comment 路 Fixed by #16137
Closed
1 task

[Bug]: References to merging enum member is lost #16133

magic-akari opened this issue Nov 28, 2023 · 1 comment 路 Fixed by #16137
Assignees
Labels
area: typescript i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@magic-akari
Copy link
Contributor

magic-akari commented Nov 28, 2023

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

enum Animals {
	Cat = 1
}

enum Animals {
	Dog = 2
}

enum Animals {
	CatDog =  Cat - Dog
}

Configuration file name

No response

Configuration

No response

Current and expected behavior

Current:

var Animals = /*#__PURE__*/function (Animals) {
  Animals[Animals["Cat"] = 1] = "Cat";
  return Animals;
}(Animals || {});
Animals = /*#__PURE__*/function (Animals) {
  Animals[Animals["Dog"] = 2] = "Dog";
  return Animals;
}(Animals || {});
Animals = function (Animals) {
  Animals[Animals["CatDog"] = Animals.Cat - Dog] = "CatDog";
  return Animals;
}(Animals || {});

Expected:

var Animals = /*#__PURE__*/function (Animals) {
  Animals[Animals["Cat"] = 1] = "Cat";
  return Animals;
}(Animals || {});
Animals = /*#__PURE__*/function (Animals) {
  Animals[Animals["Dog"] = 2] = "Dog";
  return Animals;
}(Animals || {});
Animals = function (Animals) {
  Animals[Animals["CatDog"] = Animals.Cat - Animals.Dog] = "CatDog";
  return Animals;
}(Animals || {});

Note

The Dog should be qualified

Environment

Playground:
https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=KYOwrgtgBAgiCWECGAbAzlA3gKAJAGEkAXKAXigEZsBfbbUSWBZdLPAEQHsBzMqAJhp0G0OIlQYcBYl17kohEgFoosoUA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Ctypescript&prettier=false&targets=&version=7.23.4&externalPlugins=&assumptions=%7B%7D

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @magic-akari! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@nicolo-ribaudo nicolo-ribaudo self-assigned this Nov 28, 2023
@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 Mar 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants