mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
fix(58801): "Move to file" on global code unnecessarily imports/exports, generates invalid code (#58811)
This commit is contained in:
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user