Repository navigation
fix(r3): report an empty event handler and a two-way binding that cannot be written to - #720
GabeSilvaDev wants to merge 1 commit into
Conversation
…not be written to
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5562c2a8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// so `[(x)]="a?.b.c"` is an error. Before, only a target that is itself a safe read | ||
| /// (`a?.b`) was. | ||
| pub fn rejects_safe_reads_in_two_way_bindings(&self) -> bool { | ||
| self.major > 20 || (self.major == 20 && self.minor >= 2) |
There was a problem hiding this comment.
Honor the v20.2.0-next.3 cutoff for recursive safe reads
For AngularVersion values 20.2.0-next.0 through 20.2.0-next.2, this predicate is already true even though the recursive safe-receiver check is documented as landing in 20.2.0-next.3. Compiling [(x)]="a?.b.c" against those prereleases therefore reports an unsupported binding that Angular still accepts; gate these prereleases at next.3 and cover the boundary.
Useful? React with 👍 / 👎.
Two errors ngc's binding parser reports for event bindings were missing here, so these templates compiled without a diagnostic:
(click)="",(click)=" ",(click)="// note",on-click="",(@trigger.done)=""and[(x)]="": ngc reportsEmpty expressions are not allowed(_parseAction). Here the handler was an empty expression, emitted asreturn undefined.[(ngModel)]="a + b": ngc reportsUnsupported expression in a two-way binding(_parseEvent,_isAllowedAssignmentEvent). Here it compiled toɵɵtwoWayBindingSet((ctx.a + ctx.b),$event)with no write-back, so the binding silently never updated anything.Changes
parse_event_expressionreportsEmpty expressions are not allowedfor an empty handler, or one that parses to an empty expression with no other error. Event bindings,on-bindings, legacy animation events andanimate.two-way events go through it.create_two_way_eventreports the same for an empty two-way binding, andUnsupported expression in a two-way bindingfor a target$eventcannot be written to, unless parsing already reported an error (isValidupstream). The check is_isAllowedAssignmentEvent: a property or keyed read, also behind!or$any(...)(notthis.$any(...)), and with no?.anywhere on it (hasRecursiveSafeReceiver).?.part is from Angular v20.2.0-next.3 (fix(compiler): exclude more safe reads expression from 2way-binding angular/angular#62852). Before that only a target that is itself a safe read (a?.b) was rejected, soa?.b.cwas accepted.AngularVersion::rejects_safe_reads_in_two_way_bindingskeeps that for older versions.Checks
r3_template_transform_test.rs, all cases checked against ngc 22.2.2parseTemplate: the empty handlers above;a + b,a?.b,a?.b.c,a?.[0],(a?.b).c,a(),a.b(),$any(a, b),$any(a + b),this.$any(a),!aand(a)rejected with both[(x)]andbindon-x, and[(animate.x)]="a + b";a,a.b,a[0],a!,a.b!,$any(a),$any(a.b)and(a).baccepted; no second error on a two-way binding that failed to parse.integration_test.rs:a?.b.caccepted with v20.1 and rejected with v20.2,a?.brejected with both.test_two_way_binding_writeback_target_is_never_optional_v22(from fix(chaining): preserve optional chaining in chained bindings #382) compiles[(ngModel)]="a?.b", which is now an error. It keeps its output assertions and also asserts the error, through a newcompile_template_to_js_and_errorshelper that returns the transform errors instead of panicking on them.?.check each fails a test.cargo test --all-features,cargo fmt --all -- --checkand conformance (1430/1456, snapshot unchanged) pass.Not in this PR
Event bindings on a selectorless directive (
transform_directives) still drop their parse errors, so neither of these errors is reported there.