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
Convert exported TypeScript types to undefined #10337
Comments
Hey @remcohaszing! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite. |
#10220 How's it going? |
@realduolaf #10220 fixes flow type export. It does not address this issue. |
@JLHwung OK~ Thank you. |
Is there any more news on this issue? This actually breaks builds using rollup and I’m struggling to find a workaround that doesn’t involve abandoning the Babel plugin |
In the next minor release, you'll be able to explicitly mark type-only exports using export type { foo }; |
Bug Report
Current Behavior
When the code below is compiled using webpack and
babel-loader
, this triggers the following warning:The original issue is here: babel/babel-loader#769
However, I believe it can be fixed upstream (in
@babel/plugin-transform-typescript
).Input Code
src/Bar/Bar.tsx
src/Bar/index.tsx
src/index.tsx
(Webpack entry point)Expected behavior/code
There are no warnings
Babel Configuration (.babelrc, package.json, cli command)
Environment
loader
Possible Solution
Convert exported types and interfaces to undefined constants. This way, Webpack will find the constants and stop complaining and their types are still undefined when using
typeof
checks. A minifier should strip the constant, as it is unused in the final bundle.I believe this should be an opt in solution on the Babel part. I.e. an option
typeToConst: true
for both@babel/plugin-transform-typescript
and@babel/preset-typescript
Additional context/Screenshots
This webpack config can be used to verify behaviour.
The text was updated successfully, but these errors were encountered: