fix(ivy): verify bootstrapped types are Components (#28386)

Prior to this change we didn't verify types passed to bootstrap as a part of NgModule semantics verification. Now we check whether all types passed to bootstrap are actually Components.

PR Close #28386
This commit is contained in:
Andrew Kushnir
2019-01-25 18:18:19 -08:00
committed by Jason Aden
parent 495a9dd445
commit 7d9aa67d8c
2 changed files with 27 additions and 5 deletions

View File

@ -169,6 +169,7 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
ngModule.imports &&
flatten(ngModule.imports, unwrapModuleWithProvidersImports)
.forEach(verifySemanticsOfNgModuleDef);
ngModule.bootstrap && ngModule.bootstrap.forEach(verifyCorrectBootstrapType);
ngModule.bootstrap && ngModule.bootstrap.forEach(verifyComponentIsPartOfNgModule);
ngModule.entryComponents && ngModule.entryComponents.forEach(verifyComponentIsPartOfNgModule);
}
@ -226,6 +227,13 @@ function verifySemanticsOfNgModuleDef(moduleType: NgModuleType): void {
}
}
function verifyCorrectBootstrapType(type: Type<any>) {
type = resolveForwardRef(type);
if (!getComponentDef(type)) {
errors.push(`${renderStringify(type)} cannot be used as an entry component.`);
}
}
function verifyComponentEntryComponentsIsPartOfNgModule(type: Type<any>) {
type = resolveForwardRef(type);
if (getComponentDef(type)) {