Skip to content

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Dec 21, 2025

Adds support for spread/rest syntax in the following places in the template syntax:

  • Object literals, e.g. {a: 1, ...foo}.
  • Array literals, e.g. [1, ...foo].
  • Function calls, e.g. fn(1, ...foo).

For arrays and object literals the spread arguments integrate into the existing pure function infrastructure in order to avoid re-creating the object on each change detection.

Fixes #11850.
Fixes #61800.

Note: I took a couple of commits from #66206 and #66190 to avoid conflicts.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Dec 21, 2025
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Dec 21, 2025
@ngbot ngbot bot added this to the Backlog milestone Dec 21, 2025
return this.sharedConstants.get(key)!;
}

getLiteralFactory(literal: o.LiteralArrayExpr | o.LiteralMapExpr): {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was unused so I deleted it and the related utilities.

Copy link
Member

@JeanMeche JeanMeche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside the nit, LGTM 🚀


do {
positionals.push(this.parsePipe());
positionals.push(this.next.isOperator('...') ? this.parseSpreadElement() : this.parsePipe());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we create a custom method isSpearOperator ?

Updates the expression lexer to handle spread operators.
Updates the output AST to account for spread elements.
Updates the linker to account for spread assignments in object literals.
Updates the expression AST to have support for spread elements inside object literals.
Adds support for spread expressions inside of object literals. This can be handy when constructing maps for `class` bindings.
Adds the ability to generate spread elements in the linker.
Adds spread elements to the output AST which can be used in arrays and function calls.
Updates the expression AST to support spread elements that will be used for arrays and function calls.
Expands the template syntax to support spread elements inside arrays. This can be handy for some bindings.
Updates the template syntax to support rest arguments in function calls. This can be handy for functions with a variable number of arguments.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 7, 2026
@kirjs kirjs merged commit a0dfa5f into angular:main Jan 7, 2026
20 checks passed
@kirjs
Copy link
Contributor

kirjs commented Jan 7, 2026

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support spread operator (...) in Angular templates (e.g., for [class] binding) Use the spread operator in template

3 participants