Repository navigation
fix(compiler): emit queries/viewQueries in ɵɵngDeclareComponent - #554
Merged
Merged
Conversation
With compilationMode: 'partial', components lost @ViewChild/ @ContentChild, signal queries, and `queries:` decorator metadata — the declaration map simply never carried them, so the linker had nothing to put into contentQueries/viewQuery on ɵɵdefineComponent. Upstream builds the component definition map on top of the directive map (partial/component.ts createComponentDefinitionMap), so the fix reuses the directive emitter's compile_queries_array: extracted view and content queries are threaded through PartialComponentInputs and emitted between providers and exportAs, matching upstream field order (directive.ts:74-80, verified against GOLDEN_PARTIAL.js). Signal queries bump minVersion to 17.2.0, the same rule and version the directive path already applies (directive.ts:146-149). Fixes #513
Codex Review SummaryThis 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: cb57c39a1f
ℹ️ 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".
`forwardRef(() => X)` query predicates were unwrapped at extraction and emitted bare — for components a new divergence, for directives a pre-existing one the compile_query comment already documented. A bare predicate is a TDZ hazard: ɵɵngDeclareComponent evaluates at class-definition time, before a later-declared `X` is initialized. Track `is_forward_ref` on R3QueryMetadata (set at the three try_unwrap_forward_ref sites: member decorators, signal queries, and decorator `queries:`/`member_query`), and re-wrap in compile_query via wrap_forward_ref — upstream's convertFromMaybeForwardRefExpression. Full-mode emit is untouched: its query calls run at first render, after class init, so the bare predicate is correct there. Covers the P1 review finding on #554.
Brooooooklyn
added a commit
that referenced
this pull request
Oct 7, 2026
…#555) * fix(compiler): emit queries/viewQueries in ɵɵngDeclareComponent With compilationMode: 'partial', components lost @ViewChild/ @ContentChild, signal queries, and `queries:` decorator metadata — the declaration map simply never carried them, so the linker had nothing to put into contentQueries/viewQuery on ɵɵdefineComponent. Upstream builds the component definition map on top of the directive map (partial/component.ts createComponentDefinitionMap), so the fix reuses the directive emitter's compile_queries_array: extracted view and content queries are threaded through PartialComponentInputs and emitted between providers and exportAs, matching upstream field order (directive.ts:74-80, verified against GOLDEN_PARTIAL.js). Signal queries bump minVersion to 17.2.0, the same rule and version the directive path already applies (directive.ts:146-149). Fixes #513 * fix(compiler): preserve forwardRef on query predicates in partial emit `forwardRef(() => X)` query predicates were unwrapped at extraction and emitted bare — for components a new divergence, for directives a pre-existing one the compile_query comment already documented. A bare predicate is a TDZ hazard: ɵɵngDeclareComponent evaluates at class-definition time, before a later-declared `X` is initialized. Track `is_forward_ref` on R3QueryMetadata (set at the three try_unwrap_forward_ref sites: member decorators, signal queries, and decorator `queries:`/`member_query`), and re-wrap in compile_query via wrap_forward_ref — upstream's convertFromMaybeForwardRefExpression. Full-mode emit is untouched: its query calls run at first render, after class init, so the bare predicate is correct there. Covers the P1 review finding on #554. * fix(compiler): keep defaults, async, rest in metadata arrow functions Arrows copied into decorator metadata lost what the output AST can't express: `FormalParameter.initializer` was never read (defaults dropped), `arrow.r#async` and `params.rest` were ignored. `(v: string = 'a') => v` emitted as `(v) => v` — an async factory then returned a value, not a Promise. Fall back to `make_raw_source` (types-stripped verbatim) when the arrow is async, has a rest param, or any param has an initializer — the same fallback destructured params and non-arrow function expressions already take. Also thread `source_text` through `extract_pipe_metadata_in` → `extract_constructor_deps` → `extract_param_dependency`: the pipe constructor's `@Inject(...)` arg conversion previously passed `None`, so the new fallback would have returned `None` there and degraded the dep to `ɵɵinvalidFactoryDep`. Fixes #512
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
compilationMode: 'partial',ɵɵngDeclareComponentdroppedqueries/viewQueries—@ViewChild/@ContentChild, signal queries (viewChild()/contentChild()), and thequeries:decorator field all vanished from the declaration.ɵɵngDeclareDirectivealready emitted them. The linker then had nothing to turn intocontentQueries:/viewQuery:onɵɵdefineComponent, so queries silently resolved to nothing at runtime.Fix
Upstream builds the component map on top of the directive map (
createComponentDefinitionMap→createDirectiveDefinitionMap), so this reuses the directive path wholesale:extract_class_queriesoutput (already computed incompile_component_full) is threaded intocompile_component_partialvia two newPartialComponentInputsslices.queries/viewQueriesare emitted with the directive emitter'scompile_queries_array(nowpub(crate), takes a slice), positioned betweenprovidersandexportAs— the upstream order indirective.ts:74-80, confirmed against the vendoredGOLDEN_PARTIAL.js.minVersionbumps to17.2.0when any query is signal-based — the same rule, version, and plain-assignment style the directive path applies (directive.ts:146-149).No changes to
ComponentMetadata— queries only matter for partial emit, so they ride onPartialComponentInputs.Verification
queries:decorator field, signal queries (+minVersionbump), and a fulllink()round-trip assertingviewQuery:/contentQueries:in the linkedɵɵdefineComponent.cargo test --all-featuresgreen,cargo check+--all-featuresclean,cargo fmtclean, conformance 1264/1264 (100%).partial/directive.rs:468-470documents it;property_decorators.rsunwraps inparse_query_predicate). Same behavior now inherited by components; fix belongs in sharedR3QueryMetadata/compile_queryand is a follow-up, not scope for this PR.Fixes #513