Add undefined guard

This commit is contained in:
Mohamed Hegazy
2018-05-17 11:45:34 -07:00
parent 6af5d8b940
commit 8dc9b76b6d
5 changed files with 99 additions and 8 deletions

View File

@@ -217,16 +217,18 @@ namespace ts {
function getFileReferenceForTypeName(typeName: string): FileReference | undefined {
// Elide type references for which we have imports
for (const importStatement of emittedImports) {
if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) {
const expr = importStatement.moduleReference.expression;
if (isStringLiteralLike(expr) && expr.text === typeName) {
if (emittedImports) {
for (const importStatement of emittedImports) {
if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) {
const expr = importStatement.moduleReference.expression;
if (isStringLiteralLike(expr) && expr.text === typeName) {
return undefined;
}
}
else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
return undefined;
}
}
return { fileName: typeName, pos: -1, end: -1 };
}
@@ -1325,4 +1327,4 @@ namespace ts {
}
return false;
}
}
}