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

[Feature Request] An option to simplify the enum output #3402

Closed
yangmingshan opened this issue Sep 22, 2023 · 1 comment
Closed

[Feature Request] An option to simplify the enum output #3402

yangmingshan opened this issue Sep 22, 2023 · 1 comment

Comments

@yangmingshan
Copy link

yangmingshan commented Sep 22, 2023

Standard enum output is pretty complex.

// Input
enum ElementTypes {
  ELEMENT,
  COMPONENT,
  SLOT,
  TEMPLATE
}

// Output
var ElementTypes = /* @__PURE__ */ ((ElementTypes2) => {
  ElementTypes2[ElementTypes2["ELEMENT"] = 0] = "ELEMENT";
  ElementTypes2[ElementTypes2["COMPONENT"] = 1] = "COMPONENT";
  ElementTypes2[ElementTypes2["SLOT"] = 2] = "SLOT";
  ElementTypes2[ElementTypes2["TEMPLATE"] = 3] = "TEMPLATE";
  return ElementTypes2;
})(ElementTypes || {});

But most of the time we just want a simple output.

// Input
enum ElementTypes {
  ELEMENT,
  COMPONENT,
  SLOT,
  TEMPLATE
}

// Output
var ElementTypes = {
  ELEMENT: 0,
  COMPONENT: 1,
  SLOT: 2,
  TEMPLATE: 3
}

Many people mentioned this in #128 as well.

@evanw
Copy link
Owner

evanw commented Sep 22, 2023

You are asking me to change what TypeScript enums mean and how they behave (i.e. change enums from a two-way map to a one-way map and remove support for declaration merging), but that’s not something I can do. I do not have any say in how the TypeScript language is supposed to work. You will have to take up your complaint with Microsoft themselves: https://github.com/microsoft/TypeScript/issues.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants