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

This commit is contained in:
Andrew Branch authored and GitHub committed 2025-01-30 13:49:26 -08:00
1 parent 66e1b24831
commit 739d729ecc
2 files changed
+16 -1

No files matched your search

+1 -1
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))) {
@@ -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" },
});