refactor(ivy): fix type of factory functions to allow explicit types (#30855)
Factory functions written by the compiler optionally allow an explicit type to be passed. If called with this type, an instance of the given type will be created instead of the type for which the factory was generated. This is used to power inheritance of Angular types, as if the constructor of a class is inherited from its superclass, then the factory function of the superclass must be used (it has all the DI info) to construct an instance of the derived class. This commit adjusts typings in a few places to allow factory functions to be called with this extra type parameter. PR Close #30855
This commit is contained in:

committed by
Andrew Kushnir

parent
b2937b16c3
commit
0ee09cdd7e
@ -15,7 +15,7 @@ import {assertDefined, assertEqual} from '../util/assert';
|
||||
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef} from './definition';
|
||||
import {NG_ELEMENT_ID} from './fields';
|
||||
import {DirectiveDef} from './interfaces/definition';
|
||||
import {DirectiveDef, FactoryFn} from './interfaces/definition';
|
||||
import {NO_PARENT_INJECTOR, NodeInjectorFactory, PARENT_INJECTOR, RelativeInjectorLocation, RelativeInjectorLocationFlags, TNODE, isFactory} from './interfaces/injector';
|
||||
import {AttributeMarker, TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeProviderIndexes, TNodeType} from './interfaces/node';
|
||||
import {DECLARATION_VIEW, INJECTOR, LView, TData, TVIEW, TView, T_HOST} from './interfaces/view';
|
||||
@ -637,7 +637,7 @@ export class NodeInjector implements Injector {
|
||||
/**
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵgetFactoryOf<T>(type: Type<any>): ((type: Type<T>| null) => T)|null {
|
||||
export function ɵɵgetFactoryOf<T>(type: Type<any>): FactoryFn<T>|null {
|
||||
const typeAny = type as any;
|
||||
const def = getComponentDef<T>(typeAny) || getDirectiveDef<T>(typeAny) ||
|
||||
getPipeDef<T>(typeAny) || getInjectableDef<T>(typeAny) || getInjectorDef<T>(typeAny);
|
||||
|
Reference in New Issue
Block a user