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

Enable unused Typescript enums to be removed by minifiers #4453

Closed
mischnic opened this issue Apr 27, 2022 · 1 comment · Fixed by #9558
Closed

Enable unused Typescript enums to be removed by minifiers #4453

mischnic opened this issue Apr 27, 2022 · 1 comment · Fixed by #9558
Milestone

Comments

@mischnic
Copy link
Contributor

mischnic commented Apr 27, 2022

Typescript enums should be transpiled such that they can be removed by minifiers if not used.

So

enum Test {
    Key = 1
}

currently becomes

var Test;
(function(Test) {
    Test[Test["Key"] = 1] = "Key";
})(Test || (Test = {}));

but should be

var Test = /* @__PURE__ */ ((x) => {
  x[x["Key"] = 1] = "Key";
  return x;
})(Test || {});

Context

Related issues:
Babel: babel/babel#9268
TSC: microsoft/TypeScript#27604
Terser: terser/terser#1177
Esbuild does this already: terser/terser#1177 (comment)

@swc-bot
Copy link
Collaborator

swc-bot commented Nov 7, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

4 participants