fix(ivy): semantic module check incorrectly handles nested arrays (#30993)
In View Engine, developers can pass bootstrap and entry components as nested arrays. e.g. ```ts export const MyOtherEntryComponents = [A, B, C] @NgModule({ entryComponents: [MyComp, MyOtherEntryComponents] }) ``` Currently using nested arrays for these properties causes unexpected errors to be reported in Ivy since the semantic NgModule checks aren't properly recursing into the nested entry/bootstrap components. This issue has been unveiled by enabling the strict function parameter checks. PR Close #30993
This commit is contained in:

committed by
Miško Hevery

parent
dda781ecce
commit
e061e638cb
@ -13,7 +13,7 @@ import {reflectDependencies} from '../../di/jit/util';
|
||||
import {Type} from '../../interface/type';
|
||||
import {Component} from '../../metadata';
|
||||
import {ModuleWithProviders, NgModule, NgModuleDef, NgModuleTransitiveScopes} from '../../metadata/ng_module';
|
||||
import {flatten} from '../../util/array_utils';
|
||||
import {deepForEach, flatten} from '../../util/array_utils';
|
||||
import {assertDefined} from '../../util/assert';
|
||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
||||
import {NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields';
|
||||
@ -200,9 +200,10 @@ function verifySemanticsOfNgModuleDef(
|
||||
verifySemanticsOfNgModuleImport(mod, moduleType);
|
||||
verifySemanticsOfNgModuleDef(mod, false, moduleType);
|
||||
});
|
||||
ngModule.bootstrap && ngModule.bootstrap.forEach(verifyCorrectBootstrapType);
|
||||
ngModule.bootstrap && ngModule.bootstrap.forEach(verifyComponentIsPartOfNgModule);
|
||||
ngModule.entryComponents && ngModule.entryComponents.forEach(verifyComponentIsPartOfNgModule);
|
||||
ngModule.bootstrap && deepForEach(ngModule.bootstrap, verifyCorrectBootstrapType);
|
||||
ngModule.bootstrap && deepForEach(ngModule.bootstrap, verifyComponentIsPartOfNgModule);
|
||||
ngModule.entryComponents &&
|
||||
deepForEach(ngModule.entryComponents, verifyComponentIsPartOfNgModule);
|
||||
}
|
||||
|
||||
// Throw Error if any errors were detected.
|
||||
@ -273,7 +274,7 @@ function verifySemanticsOfNgModuleDef(
|
||||
// We know we are component
|
||||
const component = getAnnotation<Component>(type, 'Component');
|
||||
if (component && component.entryComponents) {
|
||||
component.entryComponents.forEach(verifyComponentIsPartOfNgModule);
|
||||
deepForEach(component.entryComponents, verifyComponentIsPartOfNgModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user