Skip to content

fix(compiler-cli): spread raw options argument in ngp signal query metadata - #71418

Open
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:fix/ngp-signal-query-options-spread
Open

JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:fix/ngp-signal-query-options-spread

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Record the raw optionsSpan on QueryMetadata in ng-analyze when a signal query call (viewChild, viewChildren, contentChild, contentChildren) passes a second argument.
  • Spread that raw options span into { ...<options>, isSignal: true } in buildPropDecoratorsExpr (via LiteralMapSpreadAssignment) and in JIT decorator synthesis, matching ngtsc's memberMetadataFromSignalQuery and queryFunctionsTransforms.
  • Fixes two edge cases from reconstructing options out of parsed readSpan/descendants:
    • contentChild('el') with no options argument no longer emits a spurious descendants: true in setClassMetadata / JIT.
    • contentChildren('el', { descendants: false }) and contentChild('el', { descendants: false }) now preserve descendants: false instead of dropping it.

This was detected when working on #71343.

Test Plan

  • Added assertions on options_span in packages/compiler-cli/preprocessor/ng-analyze/src/analyzer/queries.rs.
  • Updated the 7 affected preprocessor golden files (//packages/compiler-cli/preprocessor/test:test).
  • Ran //packages/compiler-cli/preprocessor/ng-analyze:test, //packages/compiler-cli/preprocessor/test:test, //packages/compiler-cli/preprocessor/test:typecheck_goldens_test, //packages/compiler-cli/test/compliance/full:full_ngp, //packages/compiler-cli/test/compliance/local:local_ngp, //packages/compiler-cli/test/compliance/declaration-only:declaration-only_ngp, and //packages/compiler-cli/test/ngtsc:ngtsc_ngp.

…tadata

In ngtsc, signal query class metadata and JIT decorators spread the user's options object literal verbatim (`{ ...options, isSignal: true }`), preserving explicit options like `descendants: false` or `debugName` and avoiding extra keys when no options argument was passed.

Previously, ngp reconstructed the options object from parsed `readSpan` and `descendants` fields. That emitted a spurious `descendants: true` on bare `contentChild('x')` calls (where no options argument was provided) and dropped `descendants: false` when explicitly passed.

Record the raw `options_span` on `QueryMetadata` in `ng-analyze` and spread it via `LiteralMapSpreadAssignment` in `buildPropDecoratorsExpr` (and JIT decorator synthesis) so ngp matches ngtsc.
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 18, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 18, 2026
@JeanMeche
JeanMeche requested review from crisbeto and mattrbeck and removed request for crisbeto October 18, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant