-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TypeScript parsing bug - cascading issue with exporting of nihilated TS interface #314
Comments
This isn't really an issue with esbuild. This shouldn't be a problem if you use esbuild as a bundler, for example. It's happening because of the way Snowpack is using esbuild. This will happen with any TypeScript compiler that compiles one file at a time. I believe Babel's TypeScript compiler and even the To make sure your code can be compiled with Snowpack, you'll want to add the export type {IC} from './c'; |
Exactly, great, checked and both I was not aware of the Thanks, again |
Hi @evanw,
I just hit an interesting (probably corner case, but popular in my TS projects) where the strategy of nihilating TypeScript interfaces brings inconsistency with the final code. I also built the latest native tool and also tried npm package, with the same result.
Take for example 3 TS files with
a.ts -> b.ts -> c.ts
dependencies:c.ts
:both
esbuild
andtsc
would eliminate this interface. Good!b.ts
:tsc
would here parsec.ts
as well and understand that it is an interface and remove the export:// no export
while
esbuild
will not consultc.ts
(it can even not exist :) ) and falsely leave the export:Which hurts JS engine :)
I just stumbled upon esbuild through snowpack which is affected with this as well.
My current is in their plugin (that uses the esbuild npm package) to prefix on-the-fly (before passing to the esbuild plugin) each exported interface (internal are not an issue) with class with the same name (which will match with not removed
export {IC} from "./c";
) and prefixing the interface:This is the naive solution, but much easier than juggling with dependant TS code in the snowpack context, etc, and it is currently acceptable as I control projects' code and esbuild is not used for production in snowpack anyway (if I am correct?)
The text was updated successfully, but these errors were encountered: