(depType: Type<unknown>, importingType: Type<unknown>)
| 42 | } |
| 43 | |
| 44 | export 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 | } |
no test coverage detected
searching dependent graphs…