FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(compiler): ignore `@let` declarations in the control flow content projection diagnostic by aminesbdev · Pull Request #71173 · angular/angular · GitHub

fix(compiler): ignore @let declarations in the control flow content projection diagnostic - #71173

Open
aminesbdev wants to merge 1 commit into
angular:mainfrom
aminesbdev:fix/compiler-cli-ng8011-let-false-positive
Open

aminesbdev wants to merge 1 commit into
angular:mainfrom
aminesbdev:fix/compiler-cli-ng8011-let-false-positive

Conversation

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

NG8011 fires when a @let declaration sits next to the node at the root of a control flow block:

<form-field>
  <input />
  @if (hasError()) {
    @let message = 'Email is required';
    <span error>{{ message }}</span>
  }
</form-field>

The warning says <span error> won't be projected into the [error] slot, but it is. Since #58607 the compiler skips @let declarations when it looks for the single root node of a block. The diagnostic does its own count in TcbControlFlowContentProjectionOp.shouldCheck and still treats the @let as a second root node.

Issue Number: Fixes #71172

What is the new behavior?

shouldCheck skips @let declarations, so the diagnostic agrees with what the compiler does. I added two tests: one for the case above (no diagnostic), and one with a @let plus a stray text node, which is still reported. The first one fails without the change.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

It only removes a false-positive warning; the generated code doesn't change.

… projection diagnostic

The `controlFlowPreventingContentProjection` diagnostic (NG8011) counted `@let`
declarations as root nodes of a control flow block, so a block like
`@if (x) { @let a = 1; <div foo>{{a}}</div> }` was reported as preventing
`<div foo>` from being projected into its slot. The compiler skips `@let`
declarations when it picks the node to project (since angular#58607), so the node is
projected correctly and the warning is a false positive.

Skip `@let` declarations when counting root nodes, like the compiler does.

Fixes angular#71172
pullapprove Bot requested a review from kirjs October 4, 2026 07:38
angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 4, 2026
ngbot Bot added this to the Backlog milestone Oct 4, 2026
JoostK requested a review from crisbeto October 4, 2026 09:08

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, with @crisbeto requested for to confirm this is the desired change to make.

JoostK added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release action: presubmit The PR is in need of a google3 presubmit labels Oct 4, 2026
crisbeto removed the request for review from kirjs October 4, 2026 16:37
crisbeto removed the action: presubmit The PR is in need of a google3 presubmit label Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NG8011 is reported when an @let declaration is next to the projected node of a control flow block

4 participants


Back | FazBrowse Home | New Git URL