diff --git a/src/services/refactors/moveToFile.ts b/src/services/refactors/moveToFile.ts
index 18fd421d6d0ee..e007ee903eb26 100644
--- a/src/services/refactors/moveToFile.ts
+++ b/src/services/refactors/moveToFile.ts
@@ -1148,6 +1148,9 @@ export function getExistingLocals(sourceFile: SourceFile, statements: readonly S
if (symbol.valueDeclaration && getSourceFileOfNode(symbol.valueDeclaration).path === sourceFile.path) {
existingLocals.add(symbol);
}
+ else if (!symbol.valueDeclaration && symbol.parent?.valueDeclaration && getSourceFileOfNode(symbol.parent.valueDeclaration).path === sourceFile.path) {
+ existingLocals.add(symbol);
+ }
});
}
return existingLocals;
diff --git a/tests/cases/fourslash/moveToFile_noSelfImports3.ts b/tests/cases/fourslash/moveToFile_noSelfImports3.ts
new file mode 100644
index 0000000000000..cab782a57b4a5
--- /dev/null
+++ b/tests/cases/fourslash/moveToFile_noSelfImports3.ts
@@ -0,0 +1,25 @@
+///
+
+//@Filename: /b.ts
+////import { ISomething } from './a';
+////
+////export function [|func|](something: ISomething) {
+////}
+
+// @Filename: /a.ts
+////export interface ISomething {
+////}
+
+verify.moveToFile({
+ newFileContents: {
+ "/a.ts": `export interface ISomething {
+}
+export function func(something: ISomething) {
+}
+`,
+
+ "/b.ts": `
+`,
+ },
+ interactiveRefactorArguments: { targetFile: "/a.ts" }
+});
diff --git a/tests/cases/fourslash/moveToFile_noSelfImports4.ts b/tests/cases/fourslash/moveToFile_noSelfImports4.ts
new file mode 100644
index 0000000000000..1282562cad38c
--- /dev/null
+++ b/tests/cases/fourslash/moveToFile_noSelfImports4.ts
@@ -0,0 +1,21 @@
+///
+
+//@Filename: /b.ts
+////export type BaseTest = string;
+
+// @Filename: /a.ts
+////import { BaseTest } from "./b";
+////
+////export type [|Test|] = BaseTest;
+
+verify.moveToFile({
+ newFileContents: {
+ "/b.ts": `export type BaseTest = string;
+export type Test = BaseTest;
+`,
+
+ "/a.ts": `
+`,
+ },
+ interactiveRefactorArguments: { targetFile: "/b.ts" }
+});