Fix assertion -- an import may come from a require() call (#19667)

* Fix assertion -- an import may come from a require() call

* Add test for `import("./a")`
This commit is contained in:
Andy authored and GitHub committed 2017-11-07 07:41:21 -08:00
1 parent 9c8129eeac
commit 2fcf8b7068
2 files changed
+46 -4

No files matched your search

+4 -4
View File
@@ -237,12 +237,12 @@ namespace ts.codefix {
return parent as ImportDeclaration;
case SyntaxKind.ExternalModuleReference:
return (parent as ExternalModuleReference).parent;
case SyntaxKind.ImportEqualsDeclaration:
return parent as ImportEqualsDeclaration;
default:
Debug.assert(parent.kind === SyntaxKind.ExportDeclaration);
case SyntaxKind.ExportDeclaration:
case SyntaxKind.CallExpression: // For "require()" calls
// Ignore these, can't add imports to them.
return undefined;
default:
Debug.fail();
}
}