refactor(ivy): move directive, component and pipe factories to ngFactoryFn (#31953)
Reworks the compiler to output the factories for directives, components and pipes under a new static field called `ngFactoryFn`, instead of the usual `factory` property in their respective defs. This should eventually allow us to inject any kind of decorated class (e.g. a pipe). **Note:** these changes are the first part of the refactor and they don't include injectables. I decided to leave injectables for a follow-up PR, because there's some more cases we need to handle when it comes to their factories. Furthermore, directives, components and pipes make up most of the compiler output tests that need to be refactored and it'll make follow-up PRs easier to review if the tests are cleaned up now. This is part of the larger refactor for FW-1468. PR Close #31953
This commit is contained in:

committed by
atscott

parent
14feb56139
commit
c885178d5f
2
tools/public_api_guard/common/common.d.ts
vendored
2
tools/public_api_guard/common/common.d.ts
vendored
@ -225,6 +225,7 @@ export declare class NgClassBase {
|
||||
[key: string]: any;
|
||||
} | null;
|
||||
static ngDirectiveDef: any;
|
||||
static ngFactoryDef: any;
|
||||
}
|
||||
|
||||
export declare class NgComponentOutlet implements OnChanges, OnDestroy {
|
||||
@ -309,6 +310,7 @@ export declare class NgStyleBase {
|
||||
[key: string]: any;
|
||||
} | null;
|
||||
static ngDirectiveDef: any;
|
||||
static ngFactory: any;
|
||||
}
|
||||
|
||||
export declare class NgSwitch {
|
||||
|
5
tools/public_api_guard/core/core.d.ts
vendored
5
tools/public_api_guard/core/core.d.ts
vendored
@ -771,7 +771,6 @@ export declare function ɵɵdefineBase<T>(baseDefinition: {
|
||||
export declare function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
type: Type<T>;
|
||||
selectors: CssSelectorList;
|
||||
factory: FactoryFn<T>;
|
||||
consts: number;
|
||||
vars: number;
|
||||
inputs?: {
|
||||
@ -801,7 +800,6 @@ export declare function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
export declare const ɵɵdefineDirective: <T>(directiveDefinition: {
|
||||
type: Type<T>;
|
||||
selectors: (string | SelectorFlags)[][];
|
||||
factory: FactoryFn<T>;
|
||||
inputs?: { [P in keyof T]?: string | [string, string] | undefined; } | undefined;
|
||||
outputs?: { [P in keyof T]?: string | undefined; } | undefined;
|
||||
features?: DirectiveDefFeature[] | undefined;
|
||||
@ -836,7 +834,6 @@ export declare function ɵɵdefineNgModule<T>(def: {
|
||||
export declare function ɵɵdefinePipe<T>(pipeDef: {
|
||||
name: string;
|
||||
type: Type<T>;
|
||||
factory: FactoryFn<T>;
|
||||
pure?: boolean;
|
||||
}): never;
|
||||
|
||||
@ -871,6 +868,8 @@ export declare function ɵɵembeddedViewStart(viewBlockId: number, consts: numbe
|
||||
|
||||
export declare function ɵɵenableBindings(): void;
|
||||
|
||||
export declare type ɵɵFactoryDef<T> = () => T;
|
||||
|
||||
export declare function ɵɵgetCurrentView(): OpaqueViewState;
|
||||
|
||||
export declare function ɵɵgetFactoryOf<T>(type: Type<any>): FactoryFn<T> | null;
|
||||
|
Reference in New Issue
Block a user