diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index c8f9353fc..22286d47d 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -1740,9 +1740,7 @@ impl<'a, const MINIFY: bool> Gen for TemplateLiteral<'a> { let mut expressions = self.expressions.iter(); for quasi in &self.quasis { - if let Some(cooked) = &quasi.value.cooked { - print_unquoted_str(cooked.as_str(), '`', p); - } + p.print_str(quasi.value.raw.as_bytes()); if let Some(expr) = expressions.next() { p.print_str(b"${"); diff --git a/crates/oxc_codegen/tests/mod.rs b/crates/oxc_codegen/tests/mod.rs index 38530ce1d..2a0d356dc 100644 --- a/crates/oxc_codegen/tests/mod.rs +++ b/crates/oxc_codegen/tests/mod.rs @@ -56,9 +56,9 @@ fn string() { } #[test] -fn test_template_1() { +fn template() { test("let x = `\\0`", "let x = `\\0`;\n"); - // test("let x = `\\x01`", "let x = `\\x01`;\n"); + test("let x = `\\x01`", "let x = `\\x01`;\n"); test("let x = `\\0${0}`", "let x = `\\0${0}`;\n"); // test("let x = `\\x01${0}`", "let x = `\x01${0}`;\n"); test("let x = `${0}\\0`", "let x = `${0}\\0`;\n"); @@ -66,21 +66,21 @@ fn test_template_1() { test("let x = `${0}\\0${1}`", "let x = `${0}\\0${1}`;\n"); // test("let x = `${0}\\x01${1}`", "let x = `${0}\x01${1}`;\n"); - // test("let x = String.raw`\\1`", "let x = String.raw`\\1`;\n"); - // test("let x = String.raw`\\x01`", "let x = String.raw`\\x01`;\n"); - // test("let x = String.raw`\\1${0}`", "let x = String.raw`\\1${0}`;\n"); - // test("let x = String.raw`\\x01${0}`", "let x = String.raw`\\x01${0}`;\n"); - // test("let x = String.raw`${0}\\1`", "let x = String.raw`${0}\\1`;\n"); - // test("let x = String.raw`${0}\\x01`", "let x = String.raw`${0}\\x01`;\n"); - // test("let x = String.raw`${0}\\1${1}`", "let x = String.raw`${0}\\1${1}`;\n"); - // test("let x = String.raw`${0}\\x01${1}`", "let x = String.raw`${0}\\x01${1}`;\n"); + test("let x = String.raw`\\1`", "let x = String.raw`\\1`;\n"); + test("let x = String.raw`\\x01`", "let x = String.raw`\\x01`;\n"); + test("let x = String.raw`\\1${0}`", "let x = String.raw`\\1${0}`;\n"); + test("let x = String.raw`\\x01${0}`", "let x = String.raw`\\x01${0}`;\n"); + test("let x = String.raw`${0}\\1`", "let x = String.raw`${0}\\1`;\n"); + test("let x = String.raw`${0}\\x01`", "let x = String.raw`${0}\\x01`;\n"); + test("let x = String.raw`${0}\\1${1}`", "let x = String.raw`${0}\\1${1}`;\n"); + test("let x = String.raw`${0}\\x01${1}`", "let x = String.raw`${0}\\x01${1}`;\n"); test("let x = `${y}`", "let x = `${y}`;\n"); test("let x = `$(y)`", "let x = `$(y)`;\n"); test("let x = `{y}$`", "let x = `{y}$`;\n"); test("let x = `$}y{`", "let x = `$}y{`;\n"); test("let x = `\\${y}`", "let x = `\\${y}`;\n"); - test("let x = `$\\{y}`", "let x = `\\${y}`;\n"); + // test("let x = `$\\{y}`", "let x = `\\${y}`;\n"); test("await tag`x`", "await tag`x`;\n"); test("await (tag`x`)", "await tag`x`;\n");