diff --git a/crates/oxc_angular_compiler/src/pipeline/phases/reify/mod.rs b/crates/oxc_angular_compiler/src/pipeline/phases/reify/mod.rs index 7cb143a9e..d448662d7 100644 --- a/crates/oxc_angular_compiler/src/pipeline/phases/reify/mod.rs +++ b/crates/oxc_angular_compiler/src/pipeline/phases/reify/mod.rs @@ -874,14 +874,11 @@ fn reify_update_op<'a>( } } UpdateOp::InterpolateText(interp) => { - // Handle multiple interpolations like "{{a}} and {{b}}" - let (args, expr_count) = reify_interpolation( - allocator, - &interp.interpolation, - expressions, - root_xref, - false, - ); + // Handle multiple interpolations like "{{a}} and {{b}}" or "#{{a}}" + // has_extra_args must be true to preserve trailing empty strings — + // ɵɵtextInterpolateN always requires all positional string args. + let (args, expr_count) = + reify_interpolation(allocator, &interp.interpolation, expressions, root_xref, true); Some(create_text_interpolate_stmt_with_args(allocator, args, expr_count)) } UpdateOp::Binding(binding) => { diff --git a/crates/oxc_angular_compiler/tests/integration_test.rs b/crates/oxc_angular_compiler/tests/integration_test.rs index 490d5c8e8..1ebc200c1 100644 --- a/crates/oxc_angular_compiler/tests/integration_test.rs +++ b/crates/oxc_angular_compiler/tests/integration_test.rs @@ -171,7 +171,7 @@ fn test_html_entity_between_interpolations() { // Should produce: textInterpolate2("", ctx.a, "×", ctx.b) // Note: × (multiplication sign) = U+00D7, emitted as raw UTF-8 assert!( - js.contains("textInterpolate2(\"\",ctx.a,\"\u{00D7}\",ctx.b)"), + js.contains("textInterpolate2(\"\",ctx.a,\"\u{00D7}\",ctx.b,\"\")"), "Expected textInterpolate2 with raw times character. Got:\n{js}" ); } @@ -183,7 +183,7 @@ fn test_html_entity_at_start_of_interpolation() { // Should produce: textInterpolate1("×", ctx.a) // Note: × (multiplication sign) = U+00D7, emitted as raw UTF-8 assert!( - js.contains("textInterpolate1(\"\u{00D7}\",ctx.a)") + js.contains("textInterpolate1(\"\u{00D7}\",ctx.a,\"\")") || js.contains("textInterpolate(\"\u{00D7}\",ctx.a)"), "Expected textInterpolate with raw times character at start. Got:\n{js}" ); @@ -197,7 +197,7 @@ fn test_multiple_html_entities_between_interpolations() { // Should produce: textInterpolate2("", ctx.a, "\u{00A0}×\u{00A0}", ctx.b) // Note:   = U+00A0, × = U+00D7, both emitted as raw UTF-8 assert!( - js.contains("textInterpolate2(\"\",ctx.a,\"\u{00A0}\u{00D7}\u{00A0}\",ctx.b)"), + js.contains("textInterpolate2(\"\",ctx.a,\"\u{00A0}\u{00D7}\u{00A0}\",ctx.b,\"\")"), "Expected textInterpolate2 with raw Unicode entities. Got:\n{js}" ); } diff --git a/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_listener_with_index.snap b/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_listener_with_index.snap index 82fd90a24..dadd063a8 100644 --- a/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_listener_with_index.snap +++ b/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_listener_with_index.snap @@ -20,7 +20,7 @@ function TestComponent_For_1_Template(rf,ctx) { if ((rf & 2)) { const ɵ$index_1_r2 = ctx.$index; i0.ɵɵadvance(2); - i0.ɵɵtextInterpolate1("Remove #",ɵ$index_1_r2); + i0.ɵɵtextInterpolate1("Remove #",ɵ$index_1_r2,""); } } function TestComponent_Template(rf,ctx) { diff --git a/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_with_context_variables.snap b/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_with_context_variables.snap index fde2cd8ee..c61ea9413 100644 --- a/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_with_context_variables.snap +++ b/crates/oxc_angular_compiler/tests/snapshots/integration_test__for_with_context_variables.snap @@ -18,7 +18,7 @@ function TestComponent_For_1_Template(rf,ctx) { i0.ɵɵadvance(); i0.ɵɵclassProp("first",(ɵ$index_1_r2 === 0))("last",(ɵ$index_1_r2 === (ɵ$count_1_r3 - 1))); i0.ɵɵadvance(); - i0.ɵɵtextInterpolate2("",ɵ$index_1_r2,": ",item_r1.name); + i0.ɵɵtextInterpolate2("",ɵ$index_1_r2,": ",item_r1.name,""); } } function TestComponent_Template(rf,ctx) { diff --git a/crates/oxc_angular_compiler/tests/snapshots/integration_test__multiple_interpolations.snap b/crates/oxc_angular_compiler/tests/snapshots/integration_test__multiple_interpolations.snap index 6cb634764..d82f3f63b 100644 --- a/crates/oxc_angular_compiler/tests/snapshots/integration_test__multiple_interpolations.snap +++ b/crates/oxc_angular_compiler/tests/snapshots/integration_test__multiple_interpolations.snap @@ -10,6 +10,6 @@ function TestComponent_Template(rf,ctx) { } if ((rf & 2)) { i0.ɵɵadvance(); - i0.ɵɵtextInterpolate2("",ctx.first," and ",ctx.second); + i0.ɵɵtextInterpolate2("",ctx.first," and ",ctx.second,""); } }