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
Issues with parsing jsx #1
Comments
The following code works fine, when I do self-closing tags: export const Foo: React.FC<{ foo: string }> = ({foo}) => {
return <div />
} |
And of course, now I saw that my test used self-closing tag as well. This test fails: test('with jsx syntax', async () => {
const code = `export const Component: React.FC = () => {
console.log("hello!");
return <div>Hello</div>
}`;
const transform = (ast: AST) => {
traverse(ast, {
StringLiteral(path) {
const { node } = path;
if (node.value === 'hello!') {
path.replaceWith(types.stringLiteral('goodbye!'));
}
},
});
};
expect(() => {
transmute(code, transform);
}).not.toThrow();
}); |
Merged
I found the solution and submitted a PR #2. Hope you're okey with that 馃憤 And once again, thanks for the repo! |
Fixed in 1.2.1 馃憤 Thank you again for reporting and fixing this! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was exactly the kind of tool I was looking for, thanks for that! 馃憦
But I stumbled upon something that I really can't figure out. I have issues parsing code with JSX syntax.
Here's the way I did to reproduce:
npm init -y
) and installequivalent-exchange
(npm install equivalent-exchange
)node script.mjs
With this I get the following error thrown:
The strange thing is that when I clone this repo and try adding a test like this it all passes 馃
Do you have any ideas of what might be going wrong? At first I thought of different babel versions colliding. But since it didn't work in my very bare-bones repro either I'm suspecting it is something else.
The text was updated successfully, but these errors were encountered: