fix(ivy): ngtsc should include generic types on injectable definitions (#27037)
Analogously to directives, the `ngInjectableDef` field in .d.ts files is annotated with the type of service that it represents. If the service contains required generic type arguments, these must be included in the .d.ts file. PR Close #27037
This commit is contained in:
@ -78,6 +78,7 @@ export interface R3PipeMetadataFacade {
|
||||
export interface R3InjectableMetadataFacade {
|
||||
name: string;
|
||||
type: any;
|
||||
typeArgumentCount: number;
|
||||
ctorDeps: R3DependencyMetadataFacade[]|null;
|
||||
providedIn: any;
|
||||
useClass?: any;
|
||||
|
@ -23,9 +23,6 @@ import {convertDependencies, reflectDependencies} from './util';
|
||||
* `ngInjectableDef` onto the injectable type.
|
||||
*/
|
||||
export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
|
||||
// Allow the compilation of a class with a `@Injectable()` decorator without parameters
|
||||
const meta: Injectable = srcMeta || {providedIn: null};
|
||||
|
||||
let def: any = null;
|
||||
|
||||
// if NG_INJECTABLE_DEF is already defined on this class then don't overwrite it
|
||||
@ -34,6 +31,7 @@ export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
|
||||
Object.defineProperty(type, NG_INJECTABLE_DEF, {
|
||||
get: () => {
|
||||
if (def === null) {
|
||||
// Allow the compilation of a class with a `@Injectable()` decorator without parameters
|
||||
const meta: Injectable = srcMeta || {providedIn: null};
|
||||
const hasAProvider = isUseClassProvider(meta) || isUseFactoryProvider(meta) ||
|
||||
isUseValueProvider(meta) || isUseExistingProvider(meta);
|
||||
@ -42,6 +40,7 @@ export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
|
||||
const compilerMeta: R3InjectableMetadataFacade = {
|
||||
name: type.name,
|
||||
type: type,
|
||||
typeArgumentCount: 0,
|
||||
providedIn: meta.providedIn,
|
||||
ctorDeps: reflectDependencies(type),
|
||||
userDeps: undefined
|
||||
|
Reference in New Issue
Block a user