mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
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:
2 files changed
+46
-4
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user