🤖 Pick PR #58811 (fix(58801): "Move to file" on globa...) into release-5.5 (#58923)

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
This commit is contained in:
TypeScript Bot
2024-06-19 10:57:42 -07:00
committed by GitHub
parent 5367ae10f5
commit 7b1620bea2
4 changed files with 56 additions and 1 deletions

View File

@@ -891,7 +891,7 @@ export function getUsageInfo(oldFile: SourceFile, toMove: readonly Statement[],
const unusedImportsFromOldFile = new Set<Symbol>();
for (const statement of toMove) {
forEachReference(statement, checker, (symbol, isValidTypeOnlyUseSite) => {
if (!symbol.declarations) {
if (!symbol.declarations || isGlobalType(checker, symbol)) {
return;
}
if (existingTargetLocals.has(skipAlias(symbol, checker))) {
@@ -952,6 +952,10 @@ export function getUsageInfo(oldFile: SourceFile, toMove: readonly Statement[],
}
}
function isGlobalType(checker: TypeChecker, symbol: Symbol) {
return !!checker.resolveName(symbol.name, /*location*/ undefined, SymbolFlags.Type, /*excludeGlobals*/ false);
}
function makeUniqueFilename(proposedFilename: string, extension: string, inDirectory: string, host: LanguageServiceHost): string {
let newFilename = proposedFilename;
for (let i = 1;; i++) {