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

Function verifyStandaloneImport

packages/core/src/render3/jit/util.ts:44–87  ·  view source on GitHub ↗
(depType: Type<unknown>, importingType: Type<unknown>)

Source from the content-addressed store, hash-verified

42}
43
44export function verifyStandaloneImport(depType: Type<unknown>, importingType: Type<unknown>) {
45 if (isForwardRef(depType)) {
46 depType = resolveForwardRef(depType);
47 if (!depType) {
48 throw new Error(
49 `Expected forwardRef function, imported from "${stringifyForError(
50 importingType,
51 )}", to return a standalone entity or NgModule but got "${
52 stringifyForError(depType) || depType
53 }".`,
54 );
55 }
56 }
57
58 if (getNgModuleDef(depType) == null) {
59 const def = getComponentDef(depType) || getDirectiveDef(depType) || getPipeDef(depType);
60 if (def != null) {
61 // if a component, directive or pipe is imported make sure that it is standalone
62 if (!def.standalone) {
63 const type = getDependencyTypeForError(depType);
64 throw new Error(
65 `The "${stringifyForError(depType)}" ${type}, imported from "${stringifyForError(
66 importingType,
67 )}", is not standalone. Does the ${type} have the standalone: false flag?`,
68 );
69 }
70 } else {
71 // it can be either a module with provider or an unknown (not annotated) type
72 if (isModuleWithProviders(depType)) {
73 throw new Error(
74 `A module with providers was imported from "${stringifyForError(
75 importingType,
76 )}". Modules with providers are not supported in standalone components imports.`,
77 );
78 } else {
79 throw new Error(
80 `The "${stringifyForError(depType)}" type, imported from "${stringifyForError(
81 importingType,
82 )}", must be a standalone component / directive / pipe or an NgModule. Did you forget to add the required @Component / @Directive / @Pipe or @NgModule annotation?`,
83 );
84 }
85 }
86 }
87}

Callers 3

directiveDefsFunction · 0.90
pipeDefsFunction · 0.90

Calls 9

isForwardRefFunction · 0.90
resolveForwardRefFunction · 0.90
stringifyForErrorFunction · 0.90
getNgModuleDefFunction · 0.90
getComponentDefFunction · 0.90
getDirectiveDefFunction · 0.90
getPipeDefFunction · 0.90
isModuleWithProvidersFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…