Skip to content

Incorrect escaping with multiline strings #5638

Closed
@vmarcosp

Description

@vmarcosp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions