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

Remove unused export #110

Closed
egoist opened this issue May 14, 2020 · 1 comment
Closed

Remove unused export #110

egoist opened this issue May 14, 2020 · 1 comment

Comments

@egoist
Copy link

egoist commented May 14, 2020

ESBuild removed the types but kept the export, which results in SyntaxError.

esbuild v0.3

@evanw
Copy link
Owner

evanw commented May 14, 2020

Good catch.

Hmm, this one's tricky. Matching the TypeScript compiler's code generation for this exactly seems to potentially depend on actually evaluating types, which esbuild's approach to TypeScript compilation doesn't permit (esbuild treats type annotations as whitespace). For example, you can technically do this and the TypeScript compiler won't remove the export:

declare let Foo: any;
export {Foo};

I'm not sure if this case is important or not, since doing this causes the TypeScript compiler to generate invalid code. I think it could potentially be sufficient for real-world code bases to just remove exports for things that aren't local symbols. That will certainly fix cases like this at least. I'm going to try that and see how it goes.

@evanw evanw closed this as completed in a292bf2 May 14, 2020
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