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

Unexpected output from an exported mergeable enum #820

Open
magic-akari opened this issue Nov 22, 2023 · 2 comments
Open

Unexpected output from an exported mergeable enum #820

magic-akari opened this issue Nov 22, 2023 · 2 comments

Comments

@magic-akari
Copy link

magic-akari commented Nov 22, 2023

Description

The output of sucrase is not valid JavaScript code.

Input

export enum E {
  A = 1
}
export enum E {
  B = 2
}

Playground

https://sucrase.io/#transforms=typescript&compareWithBabel=false&compareWithTypeScript=true&code=export%20enum%20E%20%7B%0A%20%20A%20%3D%201%0A%7D%0Aexport%20enum%20E%20%7B%0A%20%20B%20%3D%202%0A%7D%0A

@alangpierce
Copy link
Owner

Thanks for reporting! And sorry for the delay.

This appears to be a case where transpiling requires tracking identifier usage across the file, which is a pain and may hurt performance, but should be possible for Sucrase. The high-level plan is to keep the first export and to remove the export for later enums of the same name.

@magic-akari
Copy link
Author

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