Commit 34a4669
fix: preserve object and array spread syntax in template bindings (#260)
* fix: preserve object and array spread syntax in template bindings
Object and array spread expressions in Angular template bindings were
silently dropped during compilation, e.g. `[prop]="{ ...base, key: val }"``
would emit `{ key: val }` with the spread lost entirely.
The fix spans the full compilation pipeline:
- ingest: handle LiteralMapKey::Spread when converting AST→IR
- ir/expression: add spreads: Vec<bool> parallel field to all literal
map/array IR types to track which entries are spreads
- resolve_names: propagate spreads through name resolution
- pure_literal_structures: emit spread entries in pure function wrappers
- reify/ir_expression: emit spread entries when lowering IR→output AST
- reify/angular_expression: handle SpreadElement in LiteralArray arm
- emit: fix convert_ast_for_pure_function_body to handle spreads in
both LiteralMap and LiteralArray
- output/ast: clone_in and chaining preserve is_spread on LiteralMapEntry
- output/oxc_converter: handle SpreadProperty in object expressions
- defer_configs, pipe_variadic: maintain spreads parallel-vec invariant
Adds 9 snapshot tests covering object spread, array spread, multiple
spreads, spread-with-pipe, spread-at-end, chained bindings, and arrow
function body spread. Adds TS NAPI tests for both object and array spread.
* fix: include spread metadata in pure function pooling key
Pooled pure-function bodies for `[a]` and `[...a]` (and object equivalents)
collided in the constant pool because the key generation for
DerivedLiteralArray/DerivedLiteralMap ignored the `spreads` parallel array,
causing one binding to silently inherit the other's runtime semantics.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* style: apply cargo fmt to integration test assertions
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 48f9fe7 commit 34a4669
37 files changed
Lines changed: 954 additions & 537 deletions
File tree
- crates/oxc_angular_compiler
- src
- class_debug_info
- class_metadata
- component
- directive
- injectable
- injector
- ir
- ng_module
- output
- pipeline
- phases
- reify
- pipe
- tests
- snapshots
- napi/angular-compiler/test
Lines changed: 21 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
Lines changed: 13 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 68 | + | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
| |||
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
93 | | - | |
94 | | - | |
| 89 | + | |
| 90 | + | |
95 | 91 | | |
96 | 92 | | |
97 | 93 | | |
| |||
156 | 152 | | |
157 | 153 | | |
158 | 154 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 155 | + | |
164 | 156 | | |
165 | 157 | | |
166 | 158 | | |
167 | 159 | | |
168 | 160 | | |
169 | 161 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
175 | 167 | | |
176 | 168 | | |
177 | 169 | | |
| |||
258 | 250 | | |
259 | 251 | | |
260 | 252 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 253 | + | |
266 | 254 | | |
267 | 255 | | |
268 | 256 | | |
| |||
0 commit comments