fix(compiler-cli): preserve non-null assertions in event side of two-way bindings by crisbeto · Pull Request #59087 · angular/angular · GitHub
Skip to content

fix(compiler-cli): preserve non-null assertions in event side of two-way bindings - #59087

Closed
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:two-way-non-null-assertions
Closed

crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:two-way-non-null-assertions

Conversation

@crisbeto

@crisbeto crisbeto commented Dec 6, 2024

Copy link
Copy Markdown
Member

Follow-up to #59002. If a two-way binding is non-null asserted, only the property side was getting the assertion since the $event is synthetic. In practice this means that there's no way to non-null assert a two-way binding. These changes fix the issue by checking if the handler is asserted and applying it to the $event assignment.

…way bindings

Follow-up to angular#59002. If a two-way binding is non-null asserted, only the property side was getting the assertion since the `$event` is synthetic. In practice this means that there's no way to non-null assert a two-way binding. These changes fix the issue by checking if the handler is asserted and applying it to the `$event` assignment.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Dec 6, 2024
@crisbeto
crisbeto requested a review from JoostK December 6, 2024 12:28

@JoostK JoostK left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this the behavior we want to have? I can see how the current behavior can also make sense; I'd interpret value! to remove null from the type of value (which it doesn't have in the test scenario) without interfering with the type of $event as that isn't mentioned anywhere.

Rewriting this into a separate input + output binding moves the assertion operator to the output-side only, making it explicit that events are assumed not to be null, whereas the shorthand syntax swallows this distinction.

@crisbeto

crisbeto commented Dec 6, 2024

Copy link
Copy Markdown
Member Author

@crisbeto crisbeto closed this Dec 9, 2024
@angular-automatic-lock-bot

Copy link
Copy Markdown

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants