mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-17 00:04:13 -05: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:
@@ -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