MCPcopy Create free account
hub / github.com/angular/angular / verifyDeclarationIsUnique

Function verifyDeclarationIsUnique

packages/core/src/render3/jit/module.ts:361–383  ·  view source on GitHub ↗
(type: Type<any>, suppressErrors: boolean)

Source from the content-addressed store, hash-verified

359 }
360
361 function verifyDeclarationIsUnique(type: Type<any>, suppressErrors: boolean) {
362 type = resolveForwardRef(type);
363 const existingModule = ownerNgModule.get(type);
364 if (existingModule && existingModule !== moduleType) {
365 if (!suppressErrors) {
366 const modules = [existingModule, moduleType].map(stringifyForError).sort();
367 errors.push(
368 `Type ${stringifyForError(type)} is part of the declarations of 2 modules: ${
369 modules[0]
370 } and ${modules[1]}! ` +
371 `Please consider moving ${stringifyForError(type)} to a higher module that imports ${
372 modules[0]
373 } and ${modules[1]}. ` +
374 `You can also create a new NgModule that exports and includes ${stringifyForError(
375 type,
376 )} then import that NgModule in ${modules[0]} and ${modules[1]}.`,
377 );
378 }
379 } else {
380 // Mark type as having owner.
381 ownerNgModule.set(type, moduleType);
382 }
383 }
384
385 function verifyComponentIsPartOfNgModule(type: Type<any>) {
386 type = resolveForwardRef(type);

Callers 1

Calls 6

resolveForwardRefFunction · 0.90
stringifyForErrorFunction · 0.90
mapMethod · 0.80
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected