Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): remove support for unassignable expressions in two-way bindings #55342

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Apr 15, 2024

Two-way bindings are meant to represent a property binding to an input and an event binding to an output, e.g. [(ngModel)]="foo" represents [ngModel]="foo" (ngModelChange)="foo = $event". Previously due to a quirk in the template parser, we accidentally supported unassignable expressions in two-way bindings.

In #54154 the quirk was fixed, but we kept support for some common expression because of internal usages. Now the internal usages have been cleaned up so the backwards-compatibility code can be deleted.

Externally a migration was added in #54630 that will automatically fix any places that depended on the old behavior.

BREAKING CHANGE:
Angular only supports writable expressions inside of two-way bindings.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release area: compiler Issues related to `ngc`, Angular's template compiler labels Apr 15, 2024
@angular-robot angular-robot bot added the detected: breaking change PR contains a commit with a breaking change label Apr 15, 2024
@crisbeto crisbeto added the action: global presubmit The PR is in need of a google3 global presubmit label Apr 15, 2024
@Input() value: any;
@Output() valueChange = new EventEmitter<any>();
}
describe('tsickle compatibility', () => {
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 suite was accidentally nested under the two-way binding one.

… bindings

Two-way bindings are meant to represent a property binding to an input and an event binding to an output, e.g. `[(ngModel)]="foo"` represents `[ngModel]="foo" (ngModelChange)="foo = $event"`. Previously due to a quirk in the template parser, we accidentally supported unassignable expressions in two-way bindings.

In angular#54154 the quirk was fixed, but we kept support or some common expression because of internal usages. Now the internal usages have been cleaned up so the backwards-compatibility code can be deleted.

Externally a migration was added in angular#54630 that will automatically fix any places that depended on the old behavior.

BREAKING CHANGE:
Angular only supports writable expressions inside of two-way bindings.
*
* This option is only present to support an automated migration away from the invalid syntax.
*/
allowInvalidAssignmentEvents?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit unfortunate that we need to keep this around a little while longer at the parser level, but it's not user-facing and the only place that enables it is the migration so once it is deleted, we can just drop it from here.

@crisbeto crisbeto marked this pull request as ready for review April 15, 2024 11:34
@crisbeto
Copy link
Member Author

Passing TGP. Marking as blocked until the last set of cleanups have landed.

@crisbeto crisbeto added state: blocked 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 action: global presubmit The PR is in need of a google3 global presubmit state: blocked labels Apr 15, 2024
@crisbeto
Copy link
Member Author

Internal failures have been cleaned up, this should be ready to go.

@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit 4eb0165.

iteriani pushed a commit to iteriani/angular that referenced this pull request Apr 18, 2024
… bindings (angular#55342)

Two-way bindings are meant to represent a property binding to an input and an event binding to an output, e.g. `[(ngModel)]="foo"` represents `[ngModel]="foo" (ngModelChange)="foo = $event"`. Previously due to a quirk in the template parser, we accidentally supported unassignable expressions in two-way bindings.

In angular#54154 the quirk was fixed, but we kept support or some common expression because of internal usages. Now the internal usages have been cleaned up so the backwards-compatibility code can be deleted.

Externally a migration was added in angular#54630 that will automatically fix any places that depended on the old behavior.

BREAKING CHANGE:
Angular only supports writable expressions inside of two-way bindings.

PR Close angular#55342
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler detected: breaking change PR contains a commit with a breaking change target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants