fix(jit): lower signal initializer APIs to synthesized propDecorators#319
Merged
Conversation
When `jit: true`, OXC's downlevel transform now detects property initializers calling `input()`, `output()`, `outputFromObservable()`, `model()`, `viewChild*()`, and `contentChild*()` and synthesizes the matching `@Input`/`@Output`/`@ViewChild`/etc. propDecorators entries the runtime JIT facade (`compileComponent`/`compileDirective` in `@angular/compiler`) needs to discover them. Without this, JIT-compiled signal components had no inputs, no outputs, and no queries at runtime — `setInput`, router bindings, and any `@Component`-level bindings into the class silently failed (NG0315/ NG0950). Mirrors `packages/compiler-cli/src/ngtsc/transform/jit/src/ initializer_api_transforms/`. Detection mirrors the AOT signal-API detector at `directive/property_decorators.rs`: bare identifier (`input()`), member access (`input.required()`), and namespaced (`core.input()`) forms are recognized, with `as`/`satisfies`/parenthesized wrappers unwrapped. Skipping rules match upstream `signal*Transform` early-return behavior: - `input()` skipped when `@Input` already decorates the field - `output()`/`outputFromObservable()` skipped when `@Output` decorates - `model()` skipped when either `@Input` or `@Output` decorates - query APIs skipped when any of `@ViewChild`/`@ViewChildren`/ `@ContentChild`/`@ContentChildren` decorates Argument positions mirror the runtime APIs: `output()` options live in `args[0]`, but `outputFromObservable()` options live in `args[1]` (the observable is `args[0]`); `input()` and `model()` options live in `args[1]` for the base form but `args[0]` for the `.required()` variant. For queries, the positional locator (`args[0]`) carries over verbatim and any options object (`args[1]`) is spread with `isSignal: true` folded in. Adds 14 focused tests at `tests/jit_signal_initializer_test.rs` covering each API, the alias-from-options path, `.required` variants, explicit-decorator-wins precedence, and the `outputFromObservable`-args[1] regression case. Closes #312. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56120e5964
ℹ️ 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".
Codex P1 review on #319: synthesized `static propDecorators` referenced bare decorator names (`Input`, `Output`, `ViewChild`, …) that a typical signal component never imports — it imports only the lowercase `input`/`output`/etc. functions. Evaluating the class therefore threw `ReferenceError: Input is not defined` before Angular's JIT facade ran. Tests passed because they only string-matched the emitted code without executing it. Match ngc's `createSyntheticAngularCoreDecoratorAccess`: synthesized decorators are now namespace-prefixed (`i0.Input`, `i0.Output`, `i0.ViewChild`, …) and a single `import * as i0 from "@angular/core"` is injected when any synthesis occurred. The import is skipped when no signal API lowering applied, so files without initializer-API usage are unchanged. Explicit field decorators continue to use the user's bare imports — only synthesized decorators are namespace-prefixed. Adds two regression tests: - `synthesized_decorators_resolve_against_angular_core_namespace_import` pins the import + prefix shape so the runtime ReferenceError can't silently reappear. - `namespace_import_skipped_when_no_synthesis_needed` guards against the opposite regression of unconditionally polluting every JIT file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Brooooooklyn
approved these changes
May 29, 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
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.
Closes #312.
Summary
input(),output(),outputFromObservable(),model(),viewChild()/viewChildren(),contentChild()/contentChildren()(and.required()variants) on classes carrying@Component/@Directive@Input/@Output/@ViewChild/etc. entries intostatic propDecoratorsso the runtime JIT facade can discover inputs, outputs, and queriespackages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/signal*Transformearly-return)Behavior changes
For a JIT-compiled class:
Before:
After:
Notes on the upstream port
input(...)),.requiredmember (input.required(...)), namespaced (core.input(...))as/satisfies/parenthesized wrappers unwrapped, matching ngc'stryParseInitializerApiinput(default, options?)/model(default, options?)— options inargs[1]input.required(options?)/model.required(options?)— options inargs[0]output(options?)— options inargs[0]outputFromObservable(observable, options?)— options inargs[1]args[0], options inargs[1](spread withisSignal: truefolded)model()emits two decorators per field:@Input({isSignal, alias, required, transform: undefined})and@Output("<alias>Change")Test plan
crates/oxc_angular_compiler/tests/jit_signal_initializer_test.rscover each API, alias-from-options,.requiredvariants, explicit-decorator-wins precedence, and theoutputFromObservableargs[1] regressioncargo test -p oxc_angular_compilerpasses — no regressions across the existing ~1200 testspackages/compiler-cli/test/compliance/test_cases/signal_inputs/)🤖 Generated with Claude Code