( moduleType: NgModuleType, allowDuplicateDeclarationsInRoot: boolean, importingModule?: NgModuleType, )
| 234 | } |
| 235 | |
| 236 | function verifySemanticsOfNgModuleDef( |
| 237 | moduleType: NgModuleType, |
| 238 | allowDuplicateDeclarationsInRoot: boolean, |
| 239 | importingModule?: NgModuleType, |
| 240 | ): void { |
| 241 | if (verifiedNgModule.get(moduleType)) return; |
| 242 | |
| 243 | // skip verifications of standalone components, directives, and pipes |
| 244 | if (isStandalone(moduleType)) return; |
| 245 | |
| 246 | verifiedNgModule.set(moduleType, true); |
| 247 | moduleType = resolveForwardRef(moduleType); |
| 248 | let ngModuleDef: NgModuleDef<any>; |
| 249 | if (importingModule) { |
| 250 | ngModuleDef = getNgModuleDef(moduleType)!; |
| 251 | if (!ngModuleDef) { |
| 252 | throw new Error( |
| 253 | `Unexpected value '${moduleType.name}' imported by the module '${importingModule.name}'. Please add an @NgModule annotation.`, |
| 254 | ); |
| 255 | } |
| 256 | } else { |
| 257 | ngModuleDef = getNgModuleDefOrThrow(moduleType); |
| 258 | } |
| 259 | const errors: string[] = []; |
| 260 | const declarations = maybeUnwrapFn(ngModuleDef.declarations); |
| 261 | const imports = maybeUnwrapFn(ngModuleDef.imports); |
| 262 | flatten(imports) |
| 263 | .map(unwrapModuleWithProvidersImports) |
| 264 | .forEach((modOrStandaloneCmpt) => { |
| 265 | verifySemanticsOfNgModuleImport(modOrStandaloneCmpt, moduleType); |
| 266 | verifySemanticsOfNgModuleDef(modOrStandaloneCmpt, false, moduleType); |
| 267 | }); |
| 268 | const exports = maybeUnwrapFn(ngModuleDef.exports); |
| 269 | declarations.forEach(verifyDeclarationsHaveDefinitions); |
| 270 | declarations.forEach(verifyDirectivesHaveSelector); |
| 271 | declarations.forEach((declarationType) => verifyNotStandalone(declarationType, moduleType)); |
| 272 | const combinedDeclarations: Type<any>[] = [ |
| 273 | ...declarations.map(resolveForwardRef), |
| 274 | ...flatten(imports.map(computeCombinedExports)).map(resolveForwardRef), |
| 275 | ]; |
| 276 | exports.forEach(verifyExportsAreDeclaredOrReExported); |
| 277 | declarations.forEach((decl) => verifyDeclarationIsUnique(decl, allowDuplicateDeclarationsInRoot)); |
| 278 | |
| 279 | const ngModule = getAnnotation<NgModule>(moduleType, 'NgModule'); |
| 280 | if (ngModule) { |
| 281 | ngModule.imports && |
| 282 | flatten(ngModule.imports) |
| 283 | .map(unwrapModuleWithProvidersImports) |
| 284 | .forEach((mod) => { |
| 285 | verifySemanticsOfNgModuleImport(mod, moduleType); |
| 286 | verifySemanticsOfNgModuleDef(mod, false, moduleType); |
| 287 | }); |
| 288 | ngModule.bootstrap && deepForEach(ngModule.bootstrap, verifyCorrectBootstrapType); |
| 289 | ngModule.bootstrap && deepForEach(ngModule.bootstrap, verifyComponentIsPartOfNgModule); |
| 290 | } |
| 291 | |
| 292 | // Throw Error if any errors were detected. |
| 293 | if (errors.length) { |
no test coverage detected
searching dependent graphs…