Skip to content

Commit

Permalink
[moveToFile] Fix symbols with empty declarations being treated as i…
Browse files Browse the repository at this point in the history
…mportable (#61084)
  • Loading branch information
andrewbranch authored Jan 30, 2025
1 parent 66e1b24 commit 739d729
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/refactors/moveToFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
15 changes: 15 additions & 0 deletions tests/cases/fourslash/moveToFile_undefined.ts
Original file line number Diff line number Diff line change
@@ -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" },
});

0 comments on commit 739d729

Please sign in to comment.