Skip to content

Commit 739d729

Browse files
authored
[moveToFile] Fix symbols with empty declarations being treated as importable (#61084)
1 parent 66e1b24 commit 739d729

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/services/refactors/moveToFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ export function getUsageInfo(oldFile: SourceFile, toMove: readonly Statement[],
886886
const unusedImportsFromOldFile = new Set<Symbol>();
887887
for (const statement of toMove) {
888888
forEachReference(statement, checker, enclosingRange, (symbol, isValidTypeOnlyUseSite) => {
889-
if (!symbol.declarations) {
889+
if (!some(symbol.declarations)) {
890890
return;
891891
}
892892
if (existingTargetLocals.has(skipAlias(symbol, checker))) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @module: esnext
4+
// @moduleResolution: bundler
5+
6+
// @Filename: /orig.ts
7+
//// [|export const variable = undefined;|]
8+
9+
verify.moveToFile({
10+
newFileContents: {
11+
"/orig.ts": "",
12+
"/new.ts": "export const variable = undefined;\n"
13+
},
14+
interactiveRefactorArguments: { targetFile: "/new.ts" },
15+
});

0 commit comments

Comments
 (0)