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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: import type {} from 'some-module'
results in invalid typescript
#14250
Comments
Hey @nicojs! 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. |
We should always print |
I'd like to work on this issue, but how can we write test for this? |
@The-x-Theorist You can add a test in |
Do we have to change the AST for type only importSpecifier to add the braces in the generator? |
I don't think we need to change the AST. We can print
May also check if we should handle this issue in |
@JLHwung Can you suggest an example for |
|
馃捇
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
Configuration file name
No response
Configuration
No configuration file
Current and expected behavior
Using this code:
Results in:
import type "some-module";
Which is invalid typescript.
Environment
7.16.12
Possible solution
I've noticed that the AST for:
And
is the exact same. See https://astexplorer.net/#/gist/3a6d7dc99689e175f667747004a015f4/2c079662c137fb0f3af1be0f7c04920a9d6a199a
I see 3 solutions:
import type {} from "some-module";
import type "some-module";
to typescript (and flow script?)Additional context
This got reported in StrykerJS: stryker-mutator/stryker-js#3386
We're using babel to parse and output files as is, after which
tsc
might need to run.The text was updated successfully, but these errors were encountered: