fix(compiler): improve error message when a module imports itself (#14646)

Closes #14644
This commit is contained in:
Dzmitry Shylovich
2017-03-07 04:00:25 +03:00
committed by Chuck Jazdzewski
parent f2adb2900d
commit 6bc6482765
2 changed files with 20 additions and 0 deletions

View File

@ -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';