fix(compiler): improve error message when a module imports itself (#14646)
Closes #14644
This commit is contained in:

committed by
Chuck Jazdzewski

parent
f2adb2900d
commit
6bc6482765
@ -425,6 +425,7 @@ export class CompileMetadataResolver {
|
||||
}
|
||||
|
||||
if (importedModuleType) {
|
||||
if (this._checkSelfImport(moduleType, importedModuleType)) return;
|
||||
const importedModuleSummary = this.getNgModuleSummary(importedModuleType);
|
||||
if (!importedModuleSummary) {
|
||||
this._reportError(
|
||||
@ -567,6 +568,15 @@ export class CompileMetadataResolver {
|
||||
return compileMeta;
|
||||
}
|
||||
|
||||
private _checkSelfImport(moduleType: Type<any>, importedModuleType: Type<any>): boolean {
|
||||
if (moduleType === importedModuleType) {
|
||||
this._reportError(
|
||||
syntaxError(`'${stringifyType(moduleType)}' module can't import itself`), moduleType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private _getTypeDescriptor(type: Type<any>): string {
|
||||
if (this._directiveResolver.isDirective(type)) {
|
||||
return 'directive';
|
||||
|
Reference in New Issue
Block a user