-
Notifications
You must be signed in to change notification settings - Fork 341
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
Incorrect print of default export of template literal #616
Comments
This bug is related to #556. The .loc information for default exports was introduced during a fix for decorated default exports: 537a5ac If I understand correctly, Recast loses .loc information on purpose, as a way of tricking the reprinter into not forgetting to print 'export default', per this comment Some things I haven't figured out:
|
fix benjamn#616, which is a bug where export default `hello` would print as the following (not valid JS): export default ``hello`` Fix by *not* nulling out .loc information for the nodes, thus enabling them to be processed by `fixTemplateLiteral`. Related: - benjamn#556 (comment) - benjamn@537a5ac
fix benjamn#616, which is a bug where export default `hello` would print as the following (not valid JS): export default ``hello`` Fix by *not* nulling out .loc information for the nodes, thus enabling them to be processed by `fixTemplateLiteral`. Related: - benjamn#556 (comment) - benjamn@537a5ac
fix benjamn#616, which is a bug where export default `hello` would print as the following (not valid JS): export default ``hello`` Fix by *not* nulling out .loc information for the nodes, thus enabling them to be processed by `fixTemplateLiteral`. Related: - benjamn#556 (comment) - benjamn@537a5ac
When printing a default export whose value is or includes a template literal, there are extra backticks in the output:
Actual behavior
The above example code logs '
${3}
', which isn't valid JSExpected behavior
The above example code should log '
${3}
'Details
Tested with Recast 0.18.1 (latest as of this writing)
Thanks for your help in figuring this out!
Deleting the two calls to 'parts.push("`")' in the
case "TemplateLiteral"
statement in printer.ts seems like it might fix the issue.The text was updated successfully, but these errors were encountered: