[moveToFile] Fix symbols with empty declarations being treated as importable (#61084)

This commit is contained in:
Andrew Branch 2025-01-30 13:49:26 -08:00 committed by GitHub
parent 66e1b24831
commit 739d729ecc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -886,7 +886,7 @@ export function getUsageInfo(oldFile: SourceFile, toMove: readonly Statement[],
const unusedImportsFromOldFile = new Set<Symbol>();
for (const statement of toMove) {
forEachReference(statement, checker, enclosingRange, (symbol, isValidTypeOnlyUseSite) => {
if (!symbol.declarations) {
if (!some(symbol.declarations)) {
return;
}
if (existingTargetLocals.has(skipAlias(symbol, checker))) {

View File

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @module: esnext
// @moduleResolution: bundler
// @Filename: /orig.ts
//// [|export const variable = undefined;|]
verify.moveToFile({
newFileContents: {
"/orig.ts": "",
"/new.ts": "export const variable = undefined;\n"
},
interactiveRefactorArguments: { targetFile: "/new.ts" },
});