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
[Bug]: Parse error when using named import "as" with babel-plugin-transform-flow-strip-types
#13520
Comments
Hey @antgamdia! 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." |
Oh wait probably a first good issue. |
Wow a first good issue. |
@takeaways Do you want to work on this? If you need any help I can write some pointers. If it is the first time that you contribute to Babel, follow these steps: (you need to have
|
Hi @nicolo-ribaudo I'd like to start working on this if possible. Any ideas on how I could get started with this issue specifically? |
I'd suggest you to search in your text editor for "isContextual("as")" and try to dig around the results. |
Amazing! Thanks @fedeci , will get on it! |
Hi, @i-seesharp are you still working on this? I would like to jump in if you've not gotten the chance to pick it up yet? |
@i-seesharp @dhrubesh Does anybody work on this issue? If not, can I take it? It will be my first issue. |
@doing-art just give them a coupe of more days to answer, then it will be yours! |
@fedeci Thank you. I will wait for the answer a couple of days more. |
@doing-art I'd say that you can take it! |
Thanks. I am starting wroking on it. |
Hello @fedeci @nicolo-ribaudo. I see that some PR has been linked to this issue and even merged. But I investigated the code of the PR and it does not seem to be related to the issue. Correct me if I am wrong. Could it be that it was linked by accident? Anyway, I opened another PR that should fix the issue. If it is already irrelevant, just close it. Thank you for your time. |
Yes, it was accidentally the wrong number 👍 |
Thank you to everyone involved in this issue and @doing-art for sending the PR with the fix. As soon as it gets released, we'll be able to remove an ugly workaround in our project :P Thanks!! |
💻
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
A file containing a named import using
as
orAs
results in a parse error when using thebabel-plugin-transform-flow-strip-types
. This plugin is used bybabelJest
when transpiling some tests including ES6 modules.For example, this excerpt belongs to a file defining a named import with name
as
, which is absolutely valid.How to get this file:
Configuration file name
No response
Configuration
Using the default config in CRA (create-react-application):
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/jest/babelTransform.js#L26-L37
Current and expected behavior
Current behavior when running
yarn test
in my app:Expected behavior: no parse errors whatsoever.
Environment
Possible solution
When enabling (using the default true value)
flow
in CRA it loads the@babel/plugin-transform-flow-strip-types'
plugin which is loading getting the AST given a file. Here is where the parse error is returned.My guess is that the parser used by this plugin is performing a wrong tokenization in the particular case of a named import with the same value as the predecessor token
as
.Additional context
I wasn't able to reproduce the parse error using the
babelParser.parse
method manually, so I guess it has something to do with thebabel-plugin-transform-flow-strip-types
plugin.More context: vmware-tanzu/kubeapps#3042 (comment)
The text was updated successfully, but these errors were encountered: