diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts
index 6d2a4872842..ad60a6da5fc 100644
--- a/src/services/refactors/moveToNewFile.ts
+++ b/src/services/refactors/moveToNewFile.ts
@@ -510,7 +510,12 @@ namespace ts.refactor {
}
const jsxNamespace = checker.getJsxNamespace(containsJsx);
+
+ // Strictly speaking, this could resolve to a symbol other than the JSX namespace.
+ // This will produce erroneous output (probably, an incorrectly copied import) but
+ // is expected to be very rare and easily reversible.
const jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, SymbolFlags.Namespace, /*excludeGlobals*/ true);
+
return !!jsxNamespaceSymbol && some(jsxNamespaceSymbol.declarations, isInImport)
? jsxNamespaceSymbol
: undefined;
diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts
new file mode 100644
index 00000000000..c63efb52dac
--- /dev/null
+++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport1.ts
@@ -0,0 +1,21 @@
+///
+
+// @jsx: preserve
+// @noLib: true
+// @libFiles: react.d.ts,lib.d.ts
+
+// @Filename: file.tsx
+//// import React = require('react');
+//// [|
;|]
+//// 1;
+
+verify.moveToNewFile({
+ newFileContents: {
+ "/tests/cases/fourslash/file.tsx":
+`1;`,
+ "/tests/cases/fourslash/newFile.tsx":
+`import React = require('react');
+;
+`,
+ }
+});
diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts
new file mode 100644
index 00000000000..a73fcb2209c
--- /dev/null
+++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport2.ts
@@ -0,0 +1,22 @@
+///
+
+// @jsx: preserve
+// @noLib: true
+// @libFiles: react.d.ts,lib.d.ts
+
+// @Filename: file.tsx
+//// import React = require('react');
+//// [|;|]
+//// ;
+
+verify.moveToNewFile({
+ newFileContents: {
+ "/tests/cases/fourslash/file.tsx":
+`import React = require('react');
+;`,
+ "/tests/cases/fourslash/newFile.tsx":
+`import React = require('react');
+;
+`,
+ }
+});
diff --git a/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts b/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts
new file mode 100644
index 00000000000..9adfa9fd14a
--- /dev/null
+++ b/tests/cases/fourslash/moveToNewFile_moveJsxImport3.ts
@@ -0,0 +1,21 @@
+///
+
+// @jsx: preserve
+// @noLib: true
+// @libFiles: react.d.ts,lib.d.ts
+
+// @Filename: file.tsx
+//// import React = require('react');
+//// [|1;|]
+//// ;
+
+verify.moveToNewFile({
+ newFileContents: {
+ "/tests/cases/fourslash/file.tsx":
+`import React = require('react');
+;`,
+ "/tests/cases/fourslash/newFile.tsx":
+`1;
+`,
+ }
+});