Skip to content

fix(partial): keep pipe ctor deps and inherited factories in ɵɵngDeclareFactory - #656

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/partial-factory-deps
Oct 29, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/partial-factory-deps

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Summary

Found while re-checking #623.

Fixes two partial-mode (compilationMode: 'partial') factory bugs. Both broke code silently after linking.

  1. @pipe lost its constructor deps. PipeMetadata::to_r3_metadata hard-coded deps: None, and the partial pipe factory turned None into deps: []. It now passes the extracted deps through, including the type-only flag. To carry that flag, pipe::R3DependencyMetadata gets a type_only_invalid field. Full mode was already right.
  2. A class that inherits its constructor got deps: [] instead of deps: null. This was true for @pipe, @Injectable and @NgModule. Now None (no constructor, but a base class) emits deps: null, and the linker turns that into ɵɵgetInheritedFactory. Directives and components were already right.

Ported from:

  • PipeDecoratorHandler.compilePartial → compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Pipe)) (compiler-cli annotations/src/pipe.ts)
  • getConstructorDependencies returns null for "no ctor + base class" (compiler-cli annotations/common/src/di.ts)
  • compileDependencies emits null as-is (compiler render3/partial/util.ts)

Before / after

class Ok {}
@Pipe({name:'p'}) export class P { constructor(o: Ok) {} transform(v: any) { return v; } }

before: ɵɵngDeclareFactory({..., type:P, deps:[],            target: i0.ɵɵFactoryTarget.Pipe})
after:  ɵɵngDeclareFactory({..., type:P, deps:[{token:Ok}],  target: i0.ɵɵFactoryTarget.Pipe})
linked: new (__ngFactoryType__ || P)(i0.ɵɵdirectiveInject(Ok, 16))
@Injectable() export class B { constructor(o: Ok) {} }
@Injectable() export class S extends B {}

before: ɵɵngDeclareFactory({..., type:S, deps:[],   target: ...Injectable})   -> linked: new S()  (Ok never injected)
after:  ɵɵngDeclareFactory({..., type:S, deps:null, target: ...Injectable})   -> linked: ɵɵgetInheritedFactory(S)

ngtsc parity cases checked (partial mode, ngtsc 22.2.3)

Every ɵfac matches ngtsc. Only the version string differs.

case ngtsc / ours now
pipe with ctor (o: Ok) deps:[{token:Ok}]
pipe with @Inject(TOK) + @Optional() deps:[{token:TOK},{token:Ok,optional:true}]
pipe, no ctor deps:[]
pipe, no ctor, extends base deps:null
injectable extends base (@Injectable() and providedIn:'root') deps:null
injectable, no ctor deps:[]
directive extends base deps:null (was already right)
component extends base deps:null (was already right)
NgModule extends base deps:null (was [])
NgModule, no ctor deps:[]

I also linked our partial output with linkAngularPackageSync. The pipe factories inject Ok/TOK with the right flags (16 / 24). Every inheriting class links to ɵɵgetInheritedFactory(X).

Checks

  • New tests in tests/partial_e2e_test.rs (4 tests: transform in partial mode, then link). All 4 fail with src stashed and pass with the fix.
  • cargo test --all-features: 3603 passed, 0 failed
  • conformance: 1264/1264, snapshot unchanged
  • cargo clippy --all-features --all-targets: no new warnings on changed lines
  • napi build-test, vitest run --dir ./test: 397/397 passed. tsc --noEmit is clean.
  • No TS files changed, so oxfmt and oxlint don't apply. known-differences.ts is unchanged because the e2e compare runs in full mode only.

🤖 Generated with Claude Code

…areFactory

Partial-mode factories lost constructor information, which broke code
silently after linking:

- A @pipe always got `deps: []`, so its constructor deps were dropped.
  `PipeMetadata::to_r3_metadata` now passes the extracted deps through
  (with the type-only flag), like ngtsc's `PipeDecoratorHandler`, which
  calls `compileDeclareFactory(toFactoryMetadata(analysis.meta,
  FactoryTarget.Pipe))` with the analyzed ctor deps
  (compiler-cli/src/ngtsc/annotations/src/pipe.ts).
- A @pipe, @Injectable or @NgModule with no constructor that extends a
  base class got `deps: []` instead of `deps: null`. `null` is what
  `getConstructorDependencies` returns for such a class
  (compiler-cli/src/ngtsc/annotations/common/src/di.ts), and
  `compileDependencies` (compiler/src/render3/partial/util.ts) emits it
  as-is so the linker uses `ɵɵgetInheritedFactory`.

Directives and components already did this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T08:05:02.578189Z ebf9b4c Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Brooooooklyn

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: ebf9b4c558

ℹ️ 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".

@Brooooooklyn
Brooooooklyn merged commit 4cefcff into main Oct 29, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/partial-factory-deps branch October 29, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant