fix(58801): "Move to file" on global code unnecessarily imports/exports, generates invalid code by a-tarasyuk · Pull Request #58811 · microsoft/TypeScript
@andrewbranch The moveToFile refactoring adds the same symbol to each declaration...
targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite);
| for (const decl of symbol.declarations) { | |
| if (isInImport(decl)) { | |
| const prevIsTypeOnly = oldImportsNeededByTargetFile.get(symbol); | |
| oldImportsNeededByTargetFile.set(symbol, [ | |
| prevIsTypeOnly === undefined ? isValidTypeOnlyUseSite : prevIsTypeOnly && isValidTypeOnlyUseSite, | |
| tryCast(decl, (d): d is codefix.ImportOrRequireAliasDeclaration => isImportSpecifier(d) || isImportClause(d) || isNamespaceImport(d) || isImportEqualsDeclaration(d) || isBindingElement(d) || isVariableDeclaration(d)), | |
| ]); | |
| } | |
| else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) { | |
| targetFileImportsFromOldFile.set(symbol, isValidTypeOnlyUseSite); | |
| } | |
| } |