Skip to content
9 changes: 8 additions & 1 deletion src/services/refactors/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ export function addTargetFileImports(
}
else if (targetSymbol.parent === undefined) {
Debug.assert(declaration !== undefined, "expected module symbol to have a declaration");
importAdder.addImportForModuleSymbol(symbol, isValidTypeOnlyUseSite, declaration);
const aliasedSymbol = checker.getAliasedSymbol(symbol);
if (aliasedSymbol.flags & SymbolFlags.Module) {
importAdder.addImportForModuleSymbol(symbol, isValidTypeOnlyUseSite, declaration);
}
else {
// If the aliased symbol is not a module, fall back to verbatim import
importAdder.addVerbatimImport(Debug.checkDefined(declaration ?? findAncestor(symbol.declarations?.[0], isAnyImportOrRequireStatement)));
}
}
else {
importAdder.addImportFromExportedSymbol(targetSymbol, isValidTypeOnlyUseSite, declaration);
Expand Down