feat(49358): use filename based on exported name (#49875)

This commit is contained in:
Oleksandr T
2022-07-28 01:41:31 +03:00
committed by GitHub
parent 5b0eea48e9
commit 94bb950008
2 changed files with 42 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ namespace ts.refactor {
const currentDirectory = getDirectoryPath(oldFile.fileName);
const extension = extensionFromPath(oldFile.fileName);
const newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host);
const newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host);
const newFileNameWithExtension = newModuleName + extension;
// If previous file was global, this is easy.
@@ -478,8 +478,8 @@ namespace ts.refactor {
}
}
function getNewModuleName(movedSymbols: ReadonlySymbolSet): string {
return movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
function getNewModuleName(importsFromNewFile: ReadonlySymbolSet, movedSymbols: ReadonlySymbolSet): string {
return importsFromNewFile.forEachEntry(symbolNameNoDefault) || movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile";
}
interface UsageInfo {