Repository navigation
fix(compiler): keep defaults, async, rest in metadata arrow functions - #555
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
`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.
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
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. |
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
Arrow functions copied into decorator metadata lost parameter defaults,
async, and rest params:This changes runtime behavior: an
asyncfactory returns a value instead of a Promise, and defaults stop applying. Root cause:convert_arrow_function_expressiononly readparam.pattern— the default lives onFormalParameter.initializer,asynconarrow.r#async, and rest onparams.rest, none of which the outputArrowFunctionExpr/FnParamcan represent.Fix
Emit the source verbatim (types stripped) via the existing
make_raw_sourcefallback when the arrow is async, has a rest param, or any param has an initializer — the same escape hatch destructured params and non-arrow function expressions already take. No output-AST changes needed; upstream'sFnParamcan't represent these either, it emitsWrappedNodeExpr(raw source) for metadata expressions.During review, a latent defect surfaced in the same path:
extract_param_dependencypassedsource_text: Nonetoconvert_oxc_expressionfor pipe constructor@Inject(...)args, so the new fallback would have returnedNonethere and degraded the dep toɵɵinvalidFactoryDep.extract_pipe_metadata_inalready received the source text but discarded it — it's now threaded throughextract_constructor_deps→extract_param_dependency.Verification
arrow_metadata_emit_test.rs— 8 tests: input transform default/async (full + partial),useFactoryasync+default+rest, pipe@Injectarrow token (full + partial, asserting noinvalidFactoryDep), and a guard that plain arrows still take the structured emit.cargo test --all-featuresgreen (44 suites),cargo checkclean both feature configs,cargo fmtclean, conformance 1264/1264.source_text: Nonepath; fixed by threading it through as described above.Fixes #512