From d9d68e73d2b59b598d1f7de03ad5faa2b6d31ee2 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 7 Aug 2024 14:27:03 +0200 Subject: [PATCH] fix(compiler): reduce chance of conflicts between generated factory and local variables (#57181) Currently we use some short variable names like `t` and `r` in the generated factory functions. They can conflict with local symbols with the same names, if they're used for DI. These changes rename the parameters to reduce the change for conflicts. Fixes #57168. PR Close #57181 --- ...i_change_detector_ref_my_other_pipe_fac.js | 2 +- ...pipe_di_change_detector_ref_my_pipe_fac.js | 2 +- .../pipes/pipes_my_pipe_fac.js | 2 +- .../pipes/pipes_my_pure_pipe_fac.js | 2 +- .../template_variables/for_of_def.js | 4 +- .../complex_selectors_other_directive_fac.js | 2 +- .../complex_selectors_some_directive_fac.js | 2 +- .../directives_child_component_fac.js | 2 +- .../directives_child_component_fac.local.js | 2 +- .../directives_my_component_fac.js | 2 +- .../directives_my_component_fac.local.js | 2 +- .../directives_some_directive_fac.js | 2 +- .../directives_some_directive_fac.local.js | 2 +- .../value_composition/no_selector_fac.js | 2 +- .../structural_directives_if_directive_fac.js | 2 +- .../structural_directives_my_component_fac.js | 2 +- .../value_composition/view_tokens_di_fac.js | 4 +- .../elements/class_style_bindings_factory.js | 2 +- .../elements/dom_factory.js | 2 +- .../elements/mathml_factory.js | 2 +- .../elements/namespace_factory.js | 2 +- .../elements/properties_factory.js | 2 +- .../property_pure_functions_factory.js | 2 +- .../elements/svg_factory.js | 2 +- .../ng_modules/basic_full.js | 4 +- .../ng_modules/basic_full.local.js | 4 +- .../ng_modules/basic_linked.js | 2 +- .../ng_modules/declarations.js | 2 +- .../ng_modules/declarations_jit_mode.js | 4 +- .../ng_modules/forward_refs.js | 6 +- .../ng_modules/forward_refs.local.js | 6 +- .../ng_modules/imports_exports.js | 8 +- .../ng_modules/imports_exports.local.js | 8 +- .../ng_modules/imports_exports_jit_mode.js | 8 +- .../ng_modules/inheritance.js | 8 +- .../ng_modules/inheritance.local.js | 8 +- .../ng_modules/providers.js | 2 +- .../ng_modules/providers.local.js | 2 +- .../di/component_factory.js | 6 +- .../di/ctor_overload_fac.js | 4 +- .../di/injectable_factory_fac.js | 4 +- .../di/pipe_and_injectable_pipe_first.js | 2 +- .../di/pipe_and_injectable_pipe_last.js | 2 +- .../di/providedin_forwardref.js | 2 +- .../di/useclass_forwardref.js | 2 +- .../di/useclass_with_deps.js | 12 +-- .../di/useclass_without_deps.js | 2 +- .../di/usefactory_with_deps.js | 12 +-- .../i18n_attribute_directive_factory.js | 6 +- ...i18n_prefix_attribute_directive_factory.js | 2 +- .../local_ref_before_listener_factory.js | 2 +- .../providers_feature_no_providers_factory.js | 2 +- .../test/ngtsc/local_compilation_spec.ts | 36 +++---- .../compiler-cli/test/ngtsc/ngtsc_spec.ts | 98 ++++++++++++------- .../compiler/src/injectable_compiler_2.ts | 8 +- packages/compiler/src/render3/r3_factory.ts | 6 +- 56 files changed, 176 insertions(+), 156 deletions(-) diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_other_pipe_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_other_pipe_fac.js index 44ed9267f76..4e8701fa497 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_other_pipe_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_other_pipe_fac.js @@ -1 +1 @@ -MyOtherPipe.ɵfac = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($i0$.ɵɵdirectiveInject($i0$.ChangeDetectorRef, 24)); }; +MyOtherPipe.ɵfac = function MyOtherPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyOtherPipe)($i0$.ɵɵdirectiveInject($i0$.ChangeDetectorRef, 24)); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_pipe_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_pipe_fac.js index 141e8128d86..74cc9a1d9b3 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_pipe_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipe_di_change_detector_ref_my_pipe_fac.js @@ -1 +1 @@ -MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)($i0$.ɵɵdirectiveInject($i0$.ChangeDetectorRef, 16)); }; +MyPipe.ɵfac = function MyPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyPipe)($i0$.ɵɵdirectiveInject($i0$.ChangeDetectorRef, 16)); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pipe_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pipe_fac.js index b09691cc3d2..e04d44c67b7 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pipe_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pipe_fac.js @@ -1 +1 @@ -MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)(); }; +MyPipe.ɵfac = function MyPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyPipe)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pure_pipe_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pure_pipe_fac.js index d0b57410cf5..6de50923531 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pure_pipe_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/pipes/pipes_my_pure_pipe_fac.js @@ -1 +1 @@ -MyPurePipe.ɵfac = function MyPurePipe_Factory(t) { return new (t || MyPurePipe)(); }; +MyPurePipe.ɵfac = function MyPurePipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyPurePipe)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/template_variables/for_of_def.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/template_variables/for_of_def.js index baa02f91cf6..1a7f72fe1a1 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/template_variables/for_of_def.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/template_variables/for_of_def.js @@ -1,3 +1,3 @@ -ForOfDirective.ɵfac = function ForOfDirective_Factory(t) { - return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject($r3$.ViewContainerRef), $r3$.ɵɵdirectiveInject($r3$.TemplateRef)); +ForOfDirective.ɵfac = function ForOfDirective_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || ForOfDirective)($r3$.ɵɵdirectiveInject($r3$.ViewContainerRef), $r3$.ɵɵdirectiveInject($r3$.TemplateRef)); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_other_directive_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_other_directive_fac.js index ac59cc15aa8..30ca12d0d84 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_other_directive_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_other_directive_fac.js @@ -1 +1 @@ -OtherDirective.ɵfac = function OtherDirective_Factory(t) {return new (t || OtherDirective)(); }; \ No newline at end of file +OtherDirective.ɵfac = function OtherDirective_Factory(__ngFactoryType__) {return new (__ngFactoryType__ || OtherDirective)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_some_directive_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_some_directive_fac.js index 8a2480188c6..2fd3fc559d2 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_some_directive_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/complex_selectors_some_directive_fac.js @@ -1 +1 @@ -SomeDirective.ɵfac = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); }; \ No newline at end of file +SomeDirective.ɵfac = function SomeDirective_Factory(__ngFactoryType__) {return new (__ngFactoryType__ || SomeDirective)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.js index c885c10b3f0..cd13c7138d0 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.js @@ -1 +1 @@ -ChildComponent.ɵfac = function ChildComponent_Factory(t) { return new (t || ChildComponent)(); }; \ No newline at end of file +ChildComponent.ɵfac = function ChildComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ChildComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.local.js index c885c10b3f0..cd13c7138d0 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_child_component_fac.local.js @@ -1 +1 @@ -ChildComponent.ɵfac = function ChildComponent_Factory(t) { return new (t || ChildComponent)(); }; \ No newline at end of file +ChildComponent.ɵfac = function ChildComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ChildComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.js index 57da070177e..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.local.js index 57da070177e..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_my_component_fac.local.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.js index 8a2480188c6..2fd3fc559d2 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.js @@ -1 +1 @@ -SomeDirective.ɵfac = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); }; \ No newline at end of file +SomeDirective.ɵfac = function SomeDirective_Factory(__ngFactoryType__) {return new (__ngFactoryType__ || SomeDirective)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.local.js index 8a2480188c6..2fd3fc559d2 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/directives_some_directive_fac.local.js @@ -1 +1 @@ -SomeDirective.ɵfac = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); }; \ No newline at end of file +SomeDirective.ɵfac = function SomeDirective_Factory(__ngFactoryType__) {return new (__ngFactoryType__ || SomeDirective)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/no_selector_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/no_selector_fac.js index c1775e79157..12b0bba8d9a 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/no_selector_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/no_selector_fac.js @@ -1 +1 @@ -EmptyOutletComponent.ɵfac = function EmptyOutletComponent_Factory(t) { return new (t || EmptyOutletComponent)(); }; \ No newline at end of file +EmptyOutletComponent.ɵfac = function EmptyOutletComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || EmptyOutletComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_fac.js index 65cca9800ac..4eb1573dd78 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_if_directive_fac.js @@ -1 +1 @@ -IfDirective.ɵfac = function IfDirective_Factory(t) { return new (t || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); }; \ No newline at end of file +IfDirective.ɵfac = function IfDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_my_component_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_my_component_fac.js index 57da070177e..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_my_component_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/structural_directives_my_component_fac.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/view_tokens_di_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/view_tokens_di_fac.js index 4b67a7826bb..0dea3e6bbe6 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/view_tokens_di_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/components_and_directives/value_composition/view_tokens_di_fac.js @@ -1,5 +1,5 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { - return new (t || MyComponent)( +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || MyComponent)( $r3$.ɵɵdirectiveInject($i$.ElementRef), $r3$.ɵɵdirectiveInject($i$.ViewContainerRef), $r3$.ɵɵdirectiveInject($i$.ChangeDetectorRef)); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/class_style_bindings_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/class_style_bindings_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/class_style_bindings_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/class_style_bindings_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/dom_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/dom_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/dom_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/dom_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/mathml_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/mathml_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/mathml_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/mathml_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/namespace_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/namespace_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/namespace_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/namespace_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/properties_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/properties_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/properties_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/properties_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/property_pure_functions_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/property_pure_functions_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/property_pure_functions_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/property_pure_functions_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/svg_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/svg_factory.js index b407377cdb1..0b81854f815 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/svg_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/elements/svg_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); } \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.js index 51ab12c9c96..9e2152f8126 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.js @@ -1,5 +1,5 @@ -BasicModule.ɵfac = function BasicModule_Factory(t) { return new (t || BasicModule)(); }; +BasicModule.ɵfac = function BasicModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BasicModule)(); }; BasicModule.ɵmod = /*@__PURE__*/ $i0$.ɵɵdefineNgModule({type: BasicModule, id: 'BasicModuleId'}); BasicModule.ɵinj = /*@__PURE__*/ $i0$.ɵɵdefineInjector({}); … -$i0$.ɵɵregisterNgModuleType(BasicModule, 'BasicModuleId'); \ No newline at end of file +$i0$.ɵɵregisterNgModuleType(BasicModule, 'BasicModuleId'); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.local.js index 51ab12c9c96..9e2152f8126 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_full.local.js @@ -1,5 +1,5 @@ -BasicModule.ɵfac = function BasicModule_Factory(t) { return new (t || BasicModule)(); }; +BasicModule.ɵfac = function BasicModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BasicModule)(); }; BasicModule.ɵmod = /*@__PURE__*/ $i0$.ɵɵdefineNgModule({type: BasicModule, id: 'BasicModuleId'}); BasicModule.ɵinj = /*@__PURE__*/ $i0$.ɵɵdefineInjector({}); … -$i0$.ɵɵregisterNgModuleType(BasicModule, 'BasicModuleId'); \ No newline at end of file +$i0$.ɵɵregisterNgModuleType(BasicModule, 'BasicModuleId'); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_linked.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_linked.js index 69334de5485..2728d578fca 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_linked.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/basic_linked.js @@ -1,4 +1,4 @@ -BasicModule.ɵfac = function BasicModule_Factory(t) { return new (t || BasicModule)(); }; +BasicModule.ɵfac = function BasicModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BasicModule)(); }; BasicModule.ɵmod = function() { $i0$.ɵɵregisterNgModuleType(BasicModule, 'BasicModuleId'); return /*@__PURE__*/ $i0$.ɵɵdefineNgModule({type: BasicModule, id: 'BasicModuleId'}); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations.js index f0c76f231f8..431eb6c63d8 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations.js @@ -7,7 +7,7 @@ BarDirective.ɵdir… QuxPipe.ɵfac… QuxPipe.ɵpipe… -FooModule.ɵfac = function FooModule_Factory(t) { return new (t || FooModule)(); }; +FooModule.ɵfac = function FooModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FooModule)(); }; FooModule.ɵmod = /*@__PURE__*/ $i0$.ɵɵdefineNgModule({type: FooModule, bootstrap: [FooComponent]}); FooModule.ɵinj = /*@__PURE__*/ $i0$.ɵɵdefineInjector({}); … diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations_jit_mode.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations_jit_mode.js index 8e36ca71499..d7e5dd53171 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations_jit_mode.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/declarations_jit_mode.js @@ -7,7 +7,7 @@ BarDirective.ɵdir… QuxPipe.ɵfac… QuxPipe.ɵpipe… -FooModule.ɵfac = function FooModule_Factory(t) { return new (t || FooModule)(); }; +FooModule.ɵfac = function FooModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FooModule)(); }; FooModule.ɵmod = /*@__PURE__*/ $i0$.ɵɵdefineNgModule({type: FooModule, bootstrap: [FooComponent], declarations: [FooComponent, BarDirective, QuxPipe]}); FooModule.ɵinj = /*@__PURE__*/ $i0$.ɵɵdefineInjector({}); … @@ -16,4 +16,4 @@ FooModule.ɵinj = /*@__PURE__*/ $i0$.ɵɵdefineInjector({}); type: NgModule, args: [{ declarations: [FooComponent, BarDirective, QuxPipe], bootstrap: [FooComponent] }] }], null, null); -})(); \ No newline at end of file +})(); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.js index 10f0c1e6cc6..e0de344dda9 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.js @@ -3,11 +3,11 @@ export function provideModule() { } … export class TestModule {} -TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }; +TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }; TestModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TestModule, imports: () => [ForwardModule] }); TestModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [provideModule()] }); … export class ForwardModule {} -ForwardModule.ɵfac = function ForwardModule_Factory(t) { return new (t || ForwardModule)(); }; +ForwardModule.ɵfac = function ForwardModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ForwardModule)(); }; ForwardModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ForwardModule }); -ForwardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); \ No newline at end of file +ForwardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.local.js index a9b18f4b719..c8f4d566e40 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/forward_refs.local.js @@ -3,13 +3,13 @@ export function provideModule() { } … class TestModule {} -TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }; +TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }; TestModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TestModule, imports: function () { return [ForwardModule]; } }); TestModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [provideModule()] }); export { TestModule }; … class ForwardModule {} -ForwardModule.ɵfac = function ForwardModule_Factory(t) { return new (t || ForwardModule)(); }; +ForwardModule.ɵfac = function ForwardModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ForwardModule)(); }; ForwardModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ForwardModule }); ForwardModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); -export { ForwardModule }; \ No newline at end of file +export { ForwardModule }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.js index bf941f5adec..467ee01c1a7 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.js @@ -1,5 +1,5 @@ export class AModule {} -AModule.ɵfac = function AModule_Factory(t) { return new (t || AModule)(); }; +AModule.ɵfac = function AModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AModule)(); }; AModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AModule }); AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); … @@ -12,7 +12,7 @@ AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); … export class BModule {} -BModule.ɵfac = function BModule_Factory(t) { return new (t || BModule)(); }; +BModule.ɵfac = function BModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BModule)(); }; BModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BModule }); BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); … @@ -25,7 +25,7 @@ BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); … export class AppModule {} -AppModule.ɵfac = function AppModule_Factory(t) { return new (t || AppModule)(); }; +AppModule.ɵfac = function AppModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AppModule)(); }; AppModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AppModule }); AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); … @@ -34,4 +34,4 @@ AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); type: NgModule, args: [{ imports: [BModule] }] }], null, null); -})(); \ No newline at end of file +})(); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.local.js index b3c10c7ac5f..7594fd99538 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports.local.js @@ -1,5 +1,5 @@ export class AModule {} -AModule.ɵfac = function AModule_Factory(t) { return new (t || AModule)(); }; +AModule.ɵfac = function AModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AModule)(); }; AModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AModule }); AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [A1Component, A2Component] }); … @@ -12,7 +12,7 @@ AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [A1Component, A2C … export class BModule {} -BModule.ɵfac = function BModule_Factory(t) { return new (t || BModule)(); }; +BModule.ɵfac = function BModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BModule)(); }; BModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BModule }); BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); … @@ -25,7 +25,7 @@ BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); … export class AppModule {} -AppModule.ɵfac = function AppModule_Factory(t) { return new (t || AppModule)(); }; +AppModule.ɵfac = function AppModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AppModule)(); }; AppModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AppModule }); AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); … @@ -34,4 +34,4 @@ AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); type: NgModule, args: [{ imports: [BModule] }] }], null, null); -})(); \ No newline at end of file +})(); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports_jit_mode.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports_jit_mode.js index 6a1c843d50d..0cc8853575b 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports_jit_mode.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/imports_exports_jit_mode.js @@ -1,5 +1,5 @@ export class AModule {} -AModule.ɵfac = function AModule_Factory(t) { return new (t || AModule)(); }; +AModule.ɵfac = function AModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AModule)(); }; AModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AModule, declarations: [A1Component, A2Component], exports: [A1Component, A2Component] }); AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); … @@ -11,7 +11,7 @@ AModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); })(); … export class BModule {} -BModule.ɵfac = function BModule_Factory(t) { return new (t || BModule)(); }; +BModule.ɵfac = function BModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BModule)(); }; BModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BModule, declarations: [B1Component, B2Component], exports: [AModule] }); BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); … @@ -23,7 +23,7 @@ BModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [AModule] }); })(); … export class AppModule {} -AppModule.ɵfac = function AppModule_Factory(t) { return new (t || AppModule)(); }; +AppModule.ɵfac = function AppModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AppModule)(); }; AppModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AppModule, imports: [BModule] }); AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); … @@ -32,4 +32,4 @@ AppModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [BModule] }); type: NgModule, args: [{ imports: [BModule] }] }], null, null); -})(); \ No newline at end of file +})(); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.js index 852ecc723c1..430c37e3464 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.js @@ -1,7 +1,7 @@ export class BaseModule { constructor(service) { this.service = service; } } -BaseModule.ɵfac = function BaseModule_Factory(t) { return new (t || BaseModule)(i0.ɵɵinject(Service)); }; +BaseModule.ɵfac = function BaseModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BaseModule)(i0.ɵɵinject(Service)); }; BaseModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BaseModule }); BaseModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [Service] }); (() => { @@ -16,8 +16,8 @@ export class BasicModule extends BaseModule { BasicModule.ɵfac = /*@__PURE__*/ (() => { let ɵBasicModule_BaseFactory; - return function BasicModule_Factory(t) { - return (ɵBasicModule_BaseFactory || (ɵBasicModule_BaseFactory = i0.ɵɵgetInheritedFactory(BasicModule)))(t || BasicModule); + return function BasicModule_Factory(__ngFactoryType__) { + return (ɵBasicModule_BaseFactory || (ɵBasicModule_BaseFactory = i0.ɵɵgetInheritedFactory(BasicModule)))(__ngFactoryType__ || BasicModule); }; })(); @@ -29,4 +29,4 @@ BasicModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); args: [{}] }], null, null); })(); -… \ No newline at end of file +… diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.local.js index 852ecc723c1..430c37e3464 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/inheritance.local.js @@ -1,7 +1,7 @@ export class BaseModule { constructor(service) { this.service = service; } } -BaseModule.ɵfac = function BaseModule_Factory(t) { return new (t || BaseModule)(i0.ɵɵinject(Service)); }; +BaseModule.ɵfac = function BaseModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BaseModule)(i0.ɵɵinject(Service)); }; BaseModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: BaseModule }); BaseModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [Service] }); (() => { @@ -16,8 +16,8 @@ export class BasicModule extends BaseModule { BasicModule.ɵfac = /*@__PURE__*/ (() => { let ɵBasicModule_BaseFactory; - return function BasicModule_Factory(t) { - return (ɵBasicModule_BaseFactory || (ɵBasicModule_BaseFactory = i0.ɵɵgetInheritedFactory(BasicModule)))(t || BasicModule); + return function BasicModule_Factory(__ngFactoryType__) { + return (ɵBasicModule_BaseFactory || (ɵBasicModule_BaseFactory = i0.ɵɵgetInheritedFactory(BasicModule)))(__ngFactoryType__ || BasicModule); }; })(); @@ -29,4 +29,4 @@ BasicModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({}); args: [{}] }], null, null); })(); -… \ No newline at end of file +… diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.js index 5638e77e299..42471e36bfa 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.js @@ -1,5 +1,5 @@ export class FooModule {} -FooModule.ɵfac = function FooModule_Factory(t) { return new (t || FooModule)(); }; +FooModule.ɵfac = function FooModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FooModule)(); }; FooModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FooModule }); FooModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [ Thing, diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.local.js b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.local.js index 5638e77e299..42471e36bfa 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.local.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_compiler_compliance/ng_modules/providers.local.js @@ -1,5 +1,5 @@ export class FooModule {} -FooModule.ɵfac = function FooModule_Factory(t) { return new (t || FooModule)(); }; +FooModule.ɵfac = function FooModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FooModule)(); }; FooModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FooModule }); FooModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [ Thing, diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/component_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/component_factory.js index 0f784bd3509..f5b36033082 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/component_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/component_factory.js @@ -1,6 +1,6 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { - return new (t || MyComponent)( +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || MyComponent)( $r3$.ɵɵinjectAttribute('name'), $r3$.ɵɵinjectAttribute(dynamicAttrName()), $r3$.ɵɵdirectiveInject(MyService), @@ -10,4 +10,4 @@ MyComponent.ɵfac = function MyComponent_Factory(t) { $r3$.ɵɵdirectiveInject(MyService, 8), $r3$.ɵɵdirectiveInject(MyService, 10) ); -} \ No newline at end of file +} diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/ctor_overload_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/ctor_overload_fac.js index 465fb48a169..9edd7e65fcc 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/ctor_overload_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/ctor_overload_fac.js @@ -1,3 +1,3 @@ -MyService.ɵfac = function MyService_Factory(t) { - return new (t || MyService)($r3$.ɵɵinject(MyDependency), $r3$.ɵɵinject(MyOptionalDependency, 8)); +MyService.ɵfac = function MyService_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || MyService)($r3$.ɵɵinject(MyDependency), $r3$.ɵɵinject(MyOptionalDependency, 8)); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/injectable_factory_fac.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/injectable_factory_fac.js index f6c3dbe787a..75c986fbbe6 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/injectable_factory_fac.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/injectable_factory_fac.js @@ -1,3 +1,3 @@ -MyService.ɵfac = function MyService_Factory(t) { - return new (t || MyService)($r3$.ɵɵinject(MyDependency)); +MyService.ɵfac = function MyService_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || MyService)($r3$.ɵɵinject(MyDependency)); } diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_first.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_first.js index f9807ae2abd..055377f81b7 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_first.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_first.js @@ -1,4 +1,4 @@ // NOTE The prov definition must be last so MyOtherPipe.fac is defined -MyOtherPipe.ɵfac = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵdirectiveInject(Service, 16)); }; +MyOtherPipe.ɵfac = function MyOtherPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyOtherPipe)($r3$.ɵɵdirectiveInject(Service, 16)); }; MyOtherPipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "myOtherPipe", type: MyOtherPipe, pure: true }); MyOtherPipe.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyOtherPipe, factory: MyOtherPipe.ɵfac }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_last.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_last.js index 5a32cb4a0b4..d6cccf35072 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_last.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/pipe_and_injectable_pipe_last.js @@ -1,4 +1,4 @@ // NOTE The prov definition must be last so MyPipe.fac is defined -MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)(i0.ɵɵdirectiveInject(Service, 16)); }; +MyPipe.ɵfac = function MyPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyPipe)(i0.ɵɵdirectiveInject(Service, 16)); }; MyPipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "myPipe", type: MyPipe, pure: true }); MyPipe.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: MyPipe, factory: MyPipe.ɵfac }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/providedin_forwardref.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/providedin_forwardref.js index 87af653f908..794e53bb9ce 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/providedin_forwardref.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/providedin_forwardref.js @@ -1,4 +1,4 @@ -Service.ɵfac = function Service_Factory(t) { return new (t || Service)($i0$.ɵɵinject(Dep)); }; +Service.ɵfac = function Service_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Service)($i0$.ɵɵinject(Dep)); }; Service.ɵprov = /*@__PURE__*/ $i0$.ɵɵdefineInjectable({ token: Service, factory: Service.ɵfac, providedIn: $i0$.forwardRef(() => Mod) }); (() => { (typeof ngDevMode === "undefined" || ngDevMode) && $i0$.ɵsetClassMetadata(Service, [{ diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_forwardref.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_forwardref.js index cb3eba00b5f..8f05fc53751 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_forwardref.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_forwardref.js @@ -1,5 +1,5 @@ SomeProvider.ɵprov = /*@__PURE__*/ $r3$.ɵɵdefineInjectable({ token: SomeProvider, - factory: t => SomeProviderImpl.ɵfac(t), + factory: __ngFactoryType__ => SomeProviderImpl.ɵfac(__ngFactoryType__), providedIn: 'root' }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.js index 489d5eecf33..3f3e2387809 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_with_deps.js @@ -1,13 +1,13 @@ MyService.ɵprov = /*@__PURE__*/ $r3$.ɵɵdefineInjectable({ token: MyService, - factory: function MyService_Factory(t) { - let r = null; - if (t) { - r = new t(); + factory: function MyService_Factory(__ngFactoryType__) { + let __ngConditionalFactory__ = null; + if (__ngFactoryType__) { + __ngConditionalFactory__ = new __ngFactoryType__(); } else { - r = new MyAlternateService($r3$.ɵɵinject(SomeDep)); + __ngConditionalFactory__ = new MyAlternateService($r3$.ɵɵinject(SomeDep)); } - return r; + return __ngConditionalFactory__; }, providedIn: 'root' }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_without_deps.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_without_deps.js index e39ecdbbfe9..0795f21e079 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_without_deps.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/useclass_without_deps.js @@ -1,5 +1,5 @@ MyService.ɵprov = /*@__PURE__*/ $r3$.ɵɵdefineInjectable({ token: MyService, - factory: t => MyAlternateService.ɵfac(t), + factory: __ngFactoryType__ => MyAlternateService.ɵfac(__ngFactoryType__), providedIn: 'root' }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/usefactory_with_deps.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/usefactory_with_deps.js index 938a0b8013c..65c31b7d5e9 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/usefactory_with_deps.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_di/di/usefactory_with_deps.js @@ -1,13 +1,13 @@ MyService.ɵprov = /*@__PURE__*/ $r3$.ɵɵdefineInjectable({ token: MyService, - factory: function MyService_Factory(t) { - let r = null; - if (t) { - r = new t(); + factory: function MyService_Factory(__ngFactoryType__) { + let __ngConditionalFactory__ = null; + if (__ngFactoryType__) { + __ngConditionalFactory__ = new __ngFactoryType__(); } else { - r = ((dep, optional) => new MyAlternateService(dep, optional))($r3$.ɵɵinject(SomeDep), $r3$.ɵɵinject(SomeDep, 8)); + __ngConditionalFactory__ = ((dep, optional) => new MyAlternateService(dep, optional))($r3$.ɵɵinject(SomeDep), $r3$.ɵɵinject(SomeDep, 8)); } - return r; + return __ngConditionalFactory__; }, providedIn: 'root' }); diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_attribute_directive_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_attribute_directive_factory.js index 4348030bd51..f4f6fa2f0e0 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_attribute_directive_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_attribute_directive_factory.js @@ -1,3 +1,3 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { - return new (t || MyComponent)(); -}; \ No newline at end of file +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { + return new (__ngFactoryType__ || MyComponent)(); +}; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_prefix_attribute_directive_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_prefix_attribute_directive_factory.js index 65ff7f57f58..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_prefix_attribute_directive_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_directives/matching/i18n_prefix_attribute_directive_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/local_ref_before_listener_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/local_ref_before_listener_factory.js index 65ff7f57f58..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/local_ref_before_listener_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_listener/local_ref_before_listener_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_providers/providers_feature_no_providers_factory.js b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_providers/providers_feature_no_providers_factory.js index 65ff7f57f58..cc13685a418 100644 --- a/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_providers/providers_feature_no_providers_factory.js +++ b/packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_providers/providers_feature_no_providers_factory.js @@ -1 +1 @@ -MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }; +MyComponent.ɵfac = function MyComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MyComponent)(); }; diff --git a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts index a3d41e3120c..be4f5ad79ea 100644 --- a/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts +++ b/packages/compiler-cli/test/ngtsc/local_compilation_spec.ts @@ -1045,7 +1045,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainComponent.ɵfac = function MainComponent_Factory(t) { return new (t || MainComponent)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, + `MainComponent.ɵfac = function MainComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainComponent)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, ); }); @@ -1082,7 +1082,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainComponent.ɵfac = function MainComponent_Factory(t) { return new (t || MainComponent)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, + `MainComponent.ɵfac = function MainComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainComponent)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, ); }); @@ -1122,7 +1122,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainDirective.ɵfac = function MainDirective_Factory(t) { return new (t || MainDirective)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, + `MainDirective.ɵfac = function MainDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainDirective)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, ); }); @@ -1157,7 +1157,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainDirective.ɵfac = function MainDirective_Factory(t) { return new (t || MainDirective)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, + `MainDirective.ɵfac = function MainDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainDirective)(i0.ɵɵdirectiveInject(i1.SomeService1), i0.ɵɵdirectiveInject(SomeService2), i0.ɵɵdirectiveInject(i2.SomeService3), i0.ɵɵdirectiveInject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN)); };`, ); }); @@ -1196,7 +1196,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainPipe.ɵfac = function MainPipe_Factory(t) { return new (t || MainPipe)(i0.ɵɵdirectiveInject(i1.SomeService1, 16), i0.ɵɵdirectiveInject(SomeService2, 16), i0.ɵɵdirectiveInject(i2.SomeService3, 16), i0.ɵɵdirectiveInject(i3.nested.SomeService4, 16), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN, 16)); };`, + `MainPipe.ɵfac = function MainPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainPipe)(i0.ɵɵdirectiveInject(i1.SomeService1, 16), i0.ɵɵdirectiveInject(SomeService2, 16), i0.ɵɵdirectiveInject(i2.SomeService3, 16), i0.ɵɵdirectiveInject(i3.nested.SomeService4, 16), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN, 16)); };`, ); }); @@ -1232,7 +1232,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainPipe.ɵfac = function MainPipe_Factory(t) { return new (t || MainPipe)(i0.ɵɵdirectiveInject(i1.SomeService1, 16), i0.ɵɵdirectiveInject(SomeService2, 16), i0.ɵɵdirectiveInject(i2.SomeService3, 16), i0.ɵɵdirectiveInject(i3.nested.SomeService4, 16), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN, 16)); };`, + `MainPipe.ɵfac = function MainPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainPipe)(i0.ɵɵdirectiveInject(i1.SomeService1, 16), i0.ɵɵdirectiveInject(SomeService2, 16), i0.ɵɵdirectiveInject(i2.SomeService3, 16), i0.ɵɵdirectiveInject(i3.nested.SomeService4, 16), i0.ɵɵinjectAttribute('title'), i0.ɵɵdirectiveInject(MESSAGE_TOKEN, 16)); };`, ); }); @@ -1267,7 +1267,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainService.ɵfac = function MainService_Factory(t) { return new (t || MainService)(i0.ɵɵinject(i1.SomeService1), i0.ɵɵinject(SomeService2), i0.ɵɵinject(i2.SomeService3), i0.ɵɵinject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵinject(MESSAGE_TOKEN)); };`, + `MainService.ɵfac = function MainService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainService)(i0.ɵɵinject(i1.SomeService1), i0.ɵɵinject(SomeService2), i0.ɵɵinject(i2.SomeService3), i0.ɵɵinject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵinject(MESSAGE_TOKEN)); };`, ); }); @@ -1301,7 +1301,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainModule.ɵfac = function MainModule_Factory(t) { return new (t || MainModule)(i0.ɵɵinject(i1.SomeService1), i0.ɵɵinject(SomeService2), i0.ɵɵinject(i2.SomeService3), i0.ɵɵinject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵinject(MESSAGE_TOKEN)); };`, + `MainModule.ɵfac = function MainModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MainModule)(i0.ɵɵinject(i1.SomeService1), i0.ɵɵinject(SomeService2), i0.ɵɵinject(i2.SomeService3), i0.ɵɵinject(i3.nested.SomeService4), i0.ɵɵinjectAttribute('title'), i0.ɵɵinject(MESSAGE_TOKEN)); };`, ); }); @@ -1324,7 +1324,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainService.ɵfac = function MainService_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MainService.ɵfac = function MainService_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1348,7 +1348,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainService.ɵfac = function MainService_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MainService.ɵfac = function MainService_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1373,7 +1373,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainService.ɵfac = function MainService_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MainService.ɵfac = function MainService_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1398,7 +1398,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MainService.ɵfac = function MainService_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MainService.ɵfac = function MainService_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1421,7 +1421,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MyDirective.ɵfac = function MyDirective_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MyDirective.ɵfac = function MyDirective_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1445,7 +1445,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MyDirective.ɵfac = function MyDirective_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MyDirective.ɵfac = function MyDirective_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1470,7 +1470,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MyDirective.ɵfac = function MyDirective_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MyDirective.ɵfac = function MyDirective_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); @@ -1495,7 +1495,7 @@ runInEachFileSystem(() => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `MyDirective.ɵfac = function MyDirective_Factory(t) { i0.ɵɵinvalidFactory(); };`, + `MyDirective.ɵfac = function MyDirective_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); };`, ); }); }); @@ -2630,7 +2630,7 @@ runInEachFileSystem(() => { 'test.ts', ` import {Component} from '@angular/core'; - + @Component({ template: '', }) @@ -2657,7 +2657,7 @@ runInEachFileSystem(() => { 'test.ts', ` import {Component} from '@angular/core'; - + @Component({ templateUrl: 'test.ng.html', }) diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index fe1745406a1..797e1b2bd4f 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -147,7 +147,7 @@ runInEachFileSystem((os: string) => { expect(jsContents).toContain('Dep.ɵprov ='); expect(jsContents).toContain('Service.ɵprov ='); expect(jsContents).toContain( - 'Service.ɵfac = function Service_Factory(t) { return new (t || Service)(i0.ɵɵinject(Dep)); };', + 'Service.ɵfac = function Service_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Service)(i0.ɵɵinject(Dep)); };', ); expect(jsContents).toContain("providedIn: 'root' })"); expect(jsContents).not.toContain('__decorate'); @@ -176,7 +176,9 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('Service.ɵprov ='); expect(jsContents).toContain('factory: () => (() => new Service())()'); - expect(jsContents).toContain('Service_Factory(t) { return new (t || Service)(); }'); + expect(jsContents).toContain( + 'Service_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Service)(); }', + ); expect(jsContents).toContain(", providedIn: 'root' });"); expect(jsContents).not.toContain('__decorate'); const dtsContents = env.getContents('test.d.ts'); @@ -204,10 +206,14 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('Service.ɵprov ='); - expect(jsContents).toContain('factory: function Service_Factory(t) { let r = null; if (t) {'); - expect(jsContents).toContain('return new (t || Service)(i0.ɵɵinject(Dep));'); - expect(jsContents).toContain('r = ((dep) => new Service(dep))(i0.ɵɵinject(Dep));'); - expect(jsContents).toContain("return r; }, providedIn: 'root' });"); + expect(jsContents).toContain( + 'factory: function Service_Factory(__ngFactoryType__) { let __ngConditionalFactory__ = null; if (__ngFactoryType__) {', + ); + expect(jsContents).toContain('return new (__ngFactoryType__ || Service)(i0.ɵɵinject(Dep));'); + expect(jsContents).toContain( + '__ngConditionalFactory__ = ((dep) => new Service(dep))(i0.ɵɵinject(Dep));', + ); + expect(jsContents).toContain("return __ngConditionalFactory__; }, providedIn: 'root' });"); expect(jsContents).not.toContain('__decorate'); const dtsContents = env.getContents('test.d.ts'); expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); @@ -238,10 +244,14 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('Service.ɵprov ='); - expect(jsContents).toContain('factory: function Service_Factory(t) { let r = null; if (t) {'); - expect(jsContents).toContain('return new (t || Service)(i0.ɵɵinject(Dep));'); - expect(jsContents).toContain('r = ((dep) => new Service(dep))(i0.ɵɵinject(Dep, 10));'); - expect(jsContents).toContain(`return r; }, providedIn: 'root' });`); + expect(jsContents).toContain( + 'factory: function Service_Factory(__ngFactoryType__) { let __ngConditionalFactory__ = null; if (__ngFactoryType__) {', + ); + expect(jsContents).toContain('return new (__ngFactoryType__ || Service)(i0.ɵɵinject(Dep));'); + expect(jsContents).toContain( + '__ngConditionalFactory__ = ((dep) => new Service(dep))(i0.ɵɵinject(Dep, 10));', + ); + expect(jsContents).toContain(`return __ngConditionalFactory__; }, providedIn: 'root' });`); expect(jsContents).not.toContain('__decorate'); const dtsContents = env.getContents('test.d.ts'); expect(dtsContents).toContain('static ɵprov: i0.ɵɵInjectableDeclaration;'); @@ -274,7 +284,7 @@ runInEachFileSystem((os: string) => { expect(jsContents).toContain('Service.ɵprov ='); expect(jsContents).toContain('Mod.ɵmod ='); expect(jsContents).toContain( - 'Service.ɵfac = function Service_Factory(t) { return new (t || Service)(i0.ɵɵinject(Dep)); };', + 'Service.ɵfac = function Service_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Service)(i0.ɵɵinject(Dep)); };', ); expect(jsContents).toContain('providedIn: i0.forwardRef(() => Mod) })'); expect(jsContents).not.toContain('__decorate'); @@ -330,8 +340,8 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `Service.ɵfac = function Service_Factory(t) { ` + - `return new (t || Service)(i0.ɵɵinject(Dep), i0.ɵɵinject(OptionalDep, 8)); };`, + `Service.ɵfac = function Service_Factory(__ngFactoryType__) { ` + + `return new (__ngFactoryType__ || Service)(i0.ɵɵinject(Dep), i0.ɵɵinject(OptionalDep, 8)); };`, ); }); @@ -704,7 +714,7 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain('Dir.ɵfac = /** @pureOrBreakMyCode */ (() => {'); expect(jsContents).toContain( - '(ɵDir_BaseFactory || (ɵDir_BaseFactory = i0.ɵɵgetInheritedFactory(Dir)))(t || Dir);', + '(ɵDir_BaseFactory || (ɵDir_BaseFactory = i0.ɵɵgetInheritedFactory(Dir)))(__ngFactoryType__ || Dir);', ); }); @@ -1444,7 +1454,7 @@ runInEachFileSystem((os: string) => { 'function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TestModule, { declarations: [TestCmp] }); })();', ); expect(jsContents).toContain( - 'TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }', + 'TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }', ); expect(jsContents).toContain('i0.ɵɵdefineInjector({});'); @@ -1601,7 +1611,7 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }', + 'TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }', ); expect(jsContents).toContain( 'i0.ɵɵdefineInjector({ imports: [OtherModule, RouterModule.forRoot(),' + @@ -1639,7 +1649,7 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }', + 'TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }', ); expect(jsContents).toContain('i0.ɵɵdefineNgModule({ type: TestModule });'); expect(jsContents).toContain( @@ -1685,7 +1695,7 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }', + 'TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }', ); expect(jsContents).toContain('i0.ɵɵdefineNgModule({ type: TestModule });'); expect(jsContents).toContain( @@ -1735,7 +1745,7 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'TestModule.ɵfac = function TestModule_Factory(t) { return new (t || TestModule)(); }', + 'TestModule.ɵfac = function TestModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestModule)(); }', ); expect(jsContents).toContain('i0.ɵɵdefineNgModule({ type: TestModule });'); expect(jsContents).toContain( @@ -2007,7 +2017,7 @@ runInEachFileSystem((os: string) => { 'TestPipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "test-pipe", type: TestPipe, pure: false })', ); expect(jsContents).toContain( - 'TestPipe.ɵfac = function TestPipe_Factory(t) { return new (t || TestPipe)(); }', + 'TestPipe.ɵfac = function TestPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestPipe)(); }', ); expect(dtsContents).toContain( 'static ɵpipe: i0.ɵɵPipeDeclaration;', @@ -2037,7 +2047,7 @@ runInEachFileSystem((os: string) => { 'TestPipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "test-pipe", type: TestPipe, pure: true })', ); expect(jsContents).toContain( - 'TestPipe.ɵfac = function TestPipe_Factory(t) { return new (t || TestPipe)(); }', + 'TestPipe.ɵfac = function TestPipe_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestPipe)(); }', ); expect(dtsContents).toContain( 'static ɵpipe: i0.ɵɵPipeDeclaration;', @@ -2066,7 +2076,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toContain('return new (t || TestPipe)(i0.ɵɵdirectiveInject(Dep, 16));'); + expect(jsContents).toContain( + 'return new (__ngFactoryType__ || TestPipe)(i0.ɵɵdirectiveInject(Dep, 16));', + ); }); it('should compile Pipes with generic types', () => { @@ -3443,7 +3455,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should not give a compile-time error if an invalid @Injectable is used with useFactory', () => { @@ -3465,7 +3479,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should not give a compile-time error if an invalid @Injectable is used with useExisting', () => { @@ -3489,7 +3505,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should not give a compile-time error if an invalid @Injectable is used with useClass', () => { @@ -3513,7 +3531,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should not give a compile-time error if an invalid @Injectable without providedIn is an abstract class', () => { @@ -3532,7 +3552,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should not give a compile-time error if an invalid @Injectable with providedIn is an abstract class', () => { @@ -3553,7 +3575,9 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); - expect(jsContents).toMatch(/function Test_Factory\(t\) { i0\.ɵɵinvalidFactory\(\)/m); + expect(jsContents).toMatch( + /function Test_Factory\(__ngFactoryType__\) { i0\.ɵɵinvalidFactory\(\)/m, + ); }); it('should give a compile-time error when a derived Directive inherits an invalid constructor', () => { @@ -3815,7 +3839,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'Test.ɵfac = function Test_Factory(t) { i0.ɵɵinvalidFactory()', + 'Test.ɵfac = function Test_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory()', ); }); @@ -3835,7 +3859,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'Test.ɵfac = function Test_Factory(t) { i0.ɵɵinvalidFactory()', + 'Test.ɵfac = function Test_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory()', ); }); @@ -4034,7 +4058,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'Test.ɵfac = function Test_Factory(t) { i0.ɵɵinvalidFactory()', + 'Test.ɵfac = function Test_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory()', ); }); }); @@ -4056,7 +4080,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'Test.ɵfac = function Test_Factory(t) { i0.ɵɵinvalidFactory()', + 'Test.ɵfac = function Test_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory()', ); }); }); @@ -4530,7 +4554,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - `FooCmp.ɵfac = function FooCmp_Factory(t) { return new (t || FooCmp)(i0.ɵɵinjectAttribute("test"), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }`, + `FooCmp.ɵfac = function FooCmp_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FooCmp)(i0.ɵɵinjectAttribute("test"), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }`, ); }); @@ -5575,13 +5599,13 @@ runInEachFileSystem((os: string) => { const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - 'function Base_Factory(t) { return new (t || Base)(i0.ɵɵinject(Dep)); }', + 'function Base_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Base)(i0.ɵɵinject(Dep)); }', ); expect(jsContents).toContain( - '(() => { let ɵChild_BaseFactory; return function Child_Factory(t) { return (ɵChild_BaseFactory || (ɵChild_BaseFactory = i0.ɵɵgetInheritedFactory(Child)))(t || Child); }; })();', + '(() => { let ɵChild_BaseFactory; return function Child_Factory(__ngFactoryType__) { return (ɵChild_BaseFactory || (ɵChild_BaseFactory = i0.ɵɵgetInheritedFactory(Child)))(__ngFactoryType__ || Child); }; })();', ); expect(jsContents).toContain( - 'function GrandChild_Factory(t) { return new (t || GrandChild)(); }', + 'function GrandChild_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || GrandChild)(); }', ); }); @@ -5607,7 +5631,7 @@ runInEachFileSystem((os: string) => { env.driveMain(); const jsContents = env.getContents('test.js'); expect(jsContents).toContain( - '/*@__PURE__*/ (() => { let ɵDir_BaseFactory; return function Dir_Factory(t) { return (ɵDir_BaseFactory || (ɵDir_BaseFactory = i0.ɵɵgetInheritedFactory(Dir)))(t || Dir); }; })();', + '/*@__PURE__*/ (() => { let ɵDir_BaseFactory; return function Dir_Factory(__ngFactoryType__) { return (ɵDir_BaseFactory || (ɵDir_BaseFactory = i0.ɵɵgetInheritedFactory(Dir)))(__ngFactoryType__ || Dir); }; })();', ); }); diff --git a/packages/compiler/src/injectable_compiler_2.ts b/packages/compiler/src/injectable_compiler_2.ts index f962832d5da..1b295513b8d 100644 --- a/packages/compiler/src/injectable_compiler_2.ts +++ b/packages/compiler/src/injectable_compiler_2.ts @@ -17,8 +17,6 @@ import { import {Identifiers} from './render3/r3_identifiers'; import { convertFromMaybeForwardRefExpression, - ForwardRefHandling, - generateForwardRef, MaybeForwardRefExpression, R3CompiledExpression, R3Reference, @@ -187,8 +185,6 @@ function delegateToFactory( } function createFactoryFunction(type: o.Expression): o.ArrowFunctionExpr { - return o.arrowFn( - [new o.FnParam('t', o.DYNAMIC_TYPE)], - type.prop('ɵfac').callFn([o.variable('t')]), - ); + const t = new o.FnParam('__ngFactoryType__', o.DYNAMIC_TYPE); + return o.arrowFn([t], type.prop('ɵfac').callFn([o.variable(t.name)])); } diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 668d8fafe48..bc8dd545190 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -111,7 +111,7 @@ export interface R3DependencyMetadata { * Construct a factory function expression for the given `R3FactoryMetadata`. */ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpression { - const t = o.variable('t'); + const t = o.variable('__ngFactoryType__'); let baseFactoryVar: o.ReadVarExpr | null = null; // The type to instantiate via constructor invocation. If there is no delegated factory, meaning @@ -139,7 +139,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre let retExpr: o.Expression | null = null; function makeConditionalFactory(nonCtorExpr: o.Expression): o.ReadVarExpr { - const r = o.variable('r'); + const r = o.variable('__ngConditionalFactory__'); body.push(r.set(o.NULL_EXPR).toDeclStmt()); const ctorStmt = ctorExpr !== null @@ -184,7 +184,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre } let factoryFn: o.Expression = o.fn( - [new o.FnParam('t', o.DYNAMIC_TYPE)], + [new o.FnParam(t.name, o.DYNAMIC_TYPE)], body, o.INFERRED_TYPE, undefined,