mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 02:15:10 -05:00
Add undefined guard
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user