Skip to content
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 escaping with multiline strings #5638

Closed
vmarcosp opened this issue Sep 6, 2022 · 1 comment · Fixed by #5639
Closed

Incorrect escaping with multiline strings #5638

vmarcosp opened this issue Sep 6, 2022 · 1 comment · Fixed by #5639
Labels
Milestone

Comments

@vmarcosp
Copy link

vmarcosp commented Sep 6, 2022

Hey 👋
I found a bug when using multiline strings + interpolation. The following code:

let bla2 = ``

let concat = () => {
   let bla = `
    display: flex;
   `
  
  `${bla}${bla2}`
}

Generates this code on v9:

var bla2 = "";

function concat(param) {
  return "\n    display: flex;\n   " + bla2;
}

exports.bla2 = bla2;
exports.concat = concat;

And this code on v10:

var bla2 = "";

function concat(param) {
  return "\\n    display: flex;\\n   " + bla2 + "";
}

There are differences on the generated code:

function concat(param) {
-  return "\n    display: flex;\n   " + bla2;
+  return "\\n    display: flex;\\n   " + bla2 + "";
}

The first one escapes multiline strings correctly, but the other is adding an unnecessary \.
Here is a reproducible example, when I switched from v10 to v9 the unnecessary \ was removed.

@vmarcosp vmarcosp changed the title Incorrect escaping with inline strings Incorrect escaping with multiline strings Sep 6, 2022
@cristianoc
Copy link
Collaborator

#5522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants