MCPcopy Index your code
hub / github.com/angular/angular / verifySemanticsOfNgModuleDef

Function verifySemanticsOfNgModuleDef

packages/core/src/render3/jit/module.ts:236–415  ·  view source on GitHub ↗
(
  moduleType: NgModuleType,
  allowDuplicateDeclarationsInRoot: boolean,
  importingModule?: NgModuleType,
)

Source from the content-addressed store, hash-verified

234}
235
236function 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) {

Callers 2

compileNgModuleDefsFunction · 0.85
computeCombinedExportsFunction · 0.85

Calls 15

isStandaloneFunction · 0.90
resolveForwardRefFunction · 0.90
getNgModuleDefFunction · 0.90
getNgModuleDefOrThrowFunction · 0.90
maybeUnwrapFnFunction · 0.90
flattenFunction · 0.90
deepForEachFunction · 0.90
verifyNotStandaloneFunction · 0.85
mapMethod · 0.80
getAnnotationFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…