Skip to content

refactor(compiler): emit any as type argument for ɵɵInjectableDeclara… - #70401

Open
atscott wants to merge 1 commit into
angular:mainfrom
atscott:fix-injectable-declaration-any-type
Open

refactor(compiler): emit any as type argument for ɵɵInjectableDeclara…#70401
atscott wants to merge 1 commit into
angular:mainfrom
atscott:fix-injectable-declaration-any-type

Conversation

@atscott

@atscott atscott commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

…tion

The static ɵprov field emitted on @Injectable() classes uses ɵɵInjectableDeclaration<T>. When a subclass extends a generic @Injectable() base class with contravariant parameters (such as callback/transformer methods depending on generic type parameters), TypeScript's static side inheritance check (typeof Sub extends typeof Super) fails with TS2417 because ɵɵInjectableDeclaration<Sub> is not assignable to ɵɵInjectableDeclaration<Super<any>>.

Using any (o.DYNAMIC_TYPE) in createInjectableType avoids strict variance checks on static inheritance for internal Ivy definitions and aligns with other Ivy declaration types.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Aug 26, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 26, 2026
@atscott
atscott force-pushed the fix-injectable-declaration-any-type branch from c0cbec6 to fcc15ce Compare August 26, 2026 16:47
@atscott
atscott requested a review from crisbeto August 26, 2026 16:48
@atscott
atscott marked this pull request as ready for review August 26, 2026 16:48
@atscott atscott added the target: patch This PR is targeted for the next patch release label Aug 26, 2026
@atscott
atscott force-pushed the fix-injectable-declaration-any-type branch from fcc15ce to 24c4dd9 Compare August 26, 2026 18:30
@pullapprove
pullapprove Bot requested review from JeanMeche and kirjs August 26, 2026 18:30

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@JeanMeche
JeanMeche removed the request for review from kirjs August 26, 2026 21:40
…tion

The static `ɵprov` field emitted on `@Injectable()` classes uses `ɵɵInjectableDeclaration<T>`.
When a subclass extends a generic `@Injectable()` base class with contravariant parameters
(such as callback/transformer methods depending on generic type parameters), TypeScript's
static side inheritance check (`typeof Sub extends typeof Super`) fails with `TS2417` because
`ɵɵInjectableDeclaration<Sub>` is not assignable to `ɵɵInjectableDeclaration<Super<any>>`.

Using `any` (`o.DYNAMIC_TYPE`) in `createInjectableType` avoids strict variance checks on
static inheritance for internal Ivy definitions and aligns with other Ivy declaration types.
@atscott
atscott force-pushed the fix-injectable-declaration-any-type branch from 24c4dd9 to 4087b5b Compare August 26, 2026 21:54
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 target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants