From 66d505e287d9f67066028286db8aadcf04e4e574 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 20 Aug 2026 12:08:07 -0700 Subject: [PATCH] =?UTF-8?q?refactor(core):=20Decouple=20=C9=B5=C9=B5Factor?= =?UTF-8?q?yDeclaration=20and=20=C9=B5=C9=B5InjectableDeclaration=20from?= =?UTF-8?q?=20type=20parameter=20T.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling under standalone compilation, generated runtime static declarations (static ɵfac and static ɵprov) are emitted into preprocessed TypeScript files and visible to the compiler during semantic typechecking. When a subclass extends a base class where the subclass is not structurally subtype-compatible with the superclass (such as differing generic type constraints, contravariant method parameters, or EventEmitter), TypeScript's class static side heritage check (TS2417) fails because ɵɵFactoryDeclaration and ɵɵInjectableDeclaration structurally referenced the instance type T. This change updates ɵɵFactoryDeclaration to return any instead of T, and sets factory return and value types in ɵɵInjectableDeclaration to any. This decouples static side inheritance from T, resolving TS2417 errors across subclassed components and injectables while preserving .d.ts metadata indexing and assignability to ɵɵdefineInjectable. This brings ɵfac and ɵprov into alignment with other Ivy declarations (ɵcmp, ɵdir, ɵpipe, ɵinj), which already treat their generic parameters as phantom metadata. --- packages/core/primitives/di/src/injection_token.ts | 4 ++-- packages/core/src/di/interface/defs.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/primitives/di/src/injection_token.ts b/packages/core/primitives/di/src/injection_token.ts index 4614855e7c3..6a0b91aec09 100644 --- a/packages/core/primitives/di/src/injection_token.ts +++ b/packages/core/primitives/di/src/injection_token.ts @@ -47,12 +47,12 @@ export interface ɵɵInjectableDeclaration { /** * Factory method to execute to create an instance of the injectable. */ - factory?: (t?: Type) => T; + factory?: (t?: Type) => any; /** * In a case of no explicit injector, a location where the instance of the injectable is stored. */ - value?: T; + value?: any; } /** diff --git a/packages/core/src/di/interface/defs.ts b/packages/core/src/di/interface/defs.ts index aef641eaa72..8d1054dfd64 100644 --- a/packages/core/src/di/interface/defs.ts +++ b/packages/core/src/di/interface/defs.ts @@ -55,12 +55,12 @@ export interface ɵɵInjectableDeclaration { /** * Factory method to execute to create an instance of the injectable. */ - factory: (t?: Type) => T; + factory: (t?: Type) => any; /** * In a case of no explicit injector, a location where the instance of the injectable is stored. */ - value: T | undefined; + value: any; } /**