-
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
Error when transforming escaped quotes #959
Comments
But Babel also throws an error on this (code here):
as does TypeScript (code here):
The JSX specification is here: https://facebook.github.io/jsx/. It doesn't say anything about backslash escape characters in strings. The relevant part of the specification is here:
It looks like the problem is that whatever tool you're using is generating invalid JSX code. Quotes in JSX strings need to be escaped with |
@evanw right on the money! JSX doesn't define any escaping semantics. To solve this one needs to switch to an expression: <span>
<Trans id={`Crisis Text Line: Text "START"`}>...</Trans>
</span> |
Wow very cool. Thanks for the detailed responses. This all has me wondering how this was working with our existing Webpack/Babel setup. Thank you very much! |
Hello,
I've originally run into this issue when building my code using Vite, but reproduced with just esbuild so posting here. When transforming the following code I get an error:
Repl: https://repl.it/@nathanforce/RemarkableFixedRefactoring
Worth noting that the original code is first run through some i18n tooling that results in the escaped quotes. I'm not sure if the output of that is the culprit here. Original TSX before running through Babel Macro:
Happy to help any way I can!
Cheers
The text was updated successfully, but these errors were encountered: