diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 6ffb0fb010714..61f372e4d55e1 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -29878,6 +29878,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found : undefined;
const jsxFactoryNamespace = getJsxNamespace(node);
const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node;
+ const shouldFactoryRefErr = compilerOptions.jsx !== JsxEmit.Preserve && compilerOptions.jsx !== JsxEmit.ReactNative;
// #38720/60122, allow null as jsxFragmentFactory
let jsxFactorySym: Symbol | undefined;
@@ -29885,7 +29886,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
jsxFactorySym = resolveName(
jsxFactoryLocation,
jsxFactoryNamespace,
- (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value,
+ shouldFactoryRefErr ? SymbolFlags.Value : SymbolFlags.Value & ~SymbolFlags.Enum,
jsxFactoryRefErr,
/*isUse*/ true,
);
@@ -29910,7 +29911,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
resolveName(
jsxFactoryLocation,
localJsxNamespace,
- (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value,
+ shouldFactoryRefErr ? SymbolFlags.Value : SymbolFlags.Value & ~SymbolFlags.Enum,
jsxFactoryRefErr,
/*isUse*/ true,
);
@@ -36669,15 +36670,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (sourceFileLinks.jsxFragmentType !== undefined) return sourceFileLinks.jsxFragmentType;
const jsxFragmentFactoryName = getJsxNamespace(node);
+
// #38720/60122, allow null as jsxFragmentFactory
- if (jsxFragmentFactoryName === "null") return sourceFileLinks.jsxFragmentType = anyType;
+ const shouldResolveFactoryReference = (compilerOptions.jsx === JsxEmit.React || compilerOptions.jsxFragmentFactory !== undefined) && jsxFragmentFactoryName !== "null";
+ if (!shouldResolveFactoryReference) return sourceFileLinks.jsxFragmentType = anyType;
+ const shouldModuleRefErr = compilerOptions.jsx !== JsxEmit.Preserve && compilerOptions.jsx !== JsxEmit.ReactNative;
const jsxFactoryRefErr = diagnostics ? Diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found : undefined;
const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ??
resolveName(
node,
jsxFragmentFactoryName,
- (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value,
+ shouldModuleRefErr ? SymbolFlags.Value : SymbolFlags.Value & ~SymbolFlags.Enum,
/*nameNotFoundMessage*/ jsxFactoryRefErr,
/*isUse*/ true,
);
diff --git a/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react).errors.txt b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react).errors.txt
new file mode 100644
index 0000000000000..a32738b88ce84
--- /dev/null
+++ b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react).errors.txt
@@ -0,0 +1,15 @@
+jsxFragmentFactoryReference.tsx(3,9): error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found.
+jsxFragmentFactoryReference.tsx(3,9): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
+
+
+==== jsxFragmentFactoryReference.tsx (2 errors) ====
+ export class LoggedOut {
+ content = () => (
+ <>>
+ ~~
+!!! error TS2874: This JSX tag requires 'React' to be in scope, but it could not be found.
+ ~~
+!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
+ )
+ }
+
\ No newline at end of file
diff --git a/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt
new file mode 100644
index 0000000000000..11dd272e65c7f
--- /dev/null
+++ b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsx).errors.txt
@@ -0,0 +1,12 @@
+jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
+
+
+==== jsxFragmentFactoryReference.tsx (1 errors) ====
+ export class LoggedOut {
+ content = () => (
+ <>>
+ ~~
+!!! error TS2792: Cannot find module 'react/jsx-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
+ )
+ }
+
\ No newline at end of file
diff --git a/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt
new file mode 100644
index 0000000000000..b9185baa77ec7
--- /dev/null
+++ b/tests/baselines/reference/jsxFragmentFactoryReference(jsx=react-jsxdev).errors.txt
@@ -0,0 +1,12 @@
+jsxFragmentFactoryReference.tsx(3,9): error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
+
+
+==== jsxFragmentFactoryReference.tsx (1 errors) ====
+ export class LoggedOut {
+ content = () => (
+ <>>
+ ~~
+!!! error TS2792: Cannot find module 'react/jsx-dev-runtime'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
+ )
+ }
+
\ No newline at end of file
diff --git a/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt b/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt
index 2b8fbaf4e46f0..248540ed384da 100644
--- a/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt
+++ b/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsx).errors.txt
@@ -1,14 +1,11 @@
jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
-jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
-==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ====
+==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ====
///
const a = <>
~~
!!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
- ~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
text
diff --git a/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt b/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt
index 31af5093deb3a..e66480f8dce2f 100644
--- a/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt
+++ b/tests/baselines/reference/jsxJsxsCjsTransformCustomImport(jsx=react-jsxdev).errors.txt
@@ -1,14 +1,11 @@
jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
-jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
-==== jsxJsxsCjsTransformCustomImport.tsx (2 errors) ====
+==== jsxJsxsCjsTransformCustomImport.tsx (1 errors) ====
///
const a = <>
~~
!!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
- ~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
text
diff --git a/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt b/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt
index 7155c43a5dad4..c37e010cab834 100644
--- a/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt
+++ b/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt
@@ -1,5 +1,4 @@
preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
-preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
==== react.tsx (0 errors) ====
@@ -13,14 +12,12 @@ preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'R
>
export {};
-==== preact.tsx (2 errors) ====
+==== preact.tsx (1 errors) ====
///
/* @jsxImportSource preact */
const a = <>
~~
!!! error TS2875: This JSX tag requires the module path 'preact/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
- ~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
text
diff --git a/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt b/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt
index ad4bb3c20b12a..79e8e02a87b2f 100644
--- a/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt
+++ b/tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsxdev).errors.txt
@@ -1,5 +1,4 @@
preact.tsx(3,11): error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
-preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
==== react.tsx (0 errors) ====
@@ -13,14 +12,12 @@ preact.tsx(3,11): error TS2879: Using JSX fragments requires fragment factory 'R
>
export {};
-==== preact.tsx (2 errors) ====
+==== preact.tsx (1 errors) ====
///
/* @jsxImportSource preact */
const a = <>
~~
!!! error TS2875: This JSX tag requires the module path 'preact/jsx-dev-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
- ~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
text
diff --git a/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).js b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).js
new file mode 100644
index 0000000000000..6310cf21524b4
--- /dev/null
+++ b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).js
@@ -0,0 +1,88 @@
+//// [tests/cases/compiler/jsxRuntimePragma.ts] ////
+
+//// [one.tsx]
+///
+/* @jsxRuntime classic */
+import * as React from "react";
+export const HelloWorld = () => Hello world
;
+export const frag = <>>;
+export const selfClosing = ;
+//// [two.tsx]
+///
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+export const frag = <>>;
+export const selfClosing = ;
+//// [three.tsx]
+///
+/* @jsxRuntime classic */
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+export const frag = <>>;
+export const selfClosing = ;
+//// [four.tsx]
+///
+/* @jsxRuntime automatic */
+/* @jsxRuntime classic */
+import * as React from "react";
+export const HelloWorld = () => Hello world
;
+export const frag = <>>;
+export const selfClosing = ;
+//// [index.ts]
+export * as one from "./one.js";
+export * as two from "./two.js";
+export * as three from "./three.js";
+export * as four from "./four.js";
+
+//// [one.jsx]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
+///
+/* @jsxRuntime classic */
+var React = require("react");
+var HelloWorld = function () { return Hello world
; };
+exports.HelloWorld = HelloWorld;
+exports.frag = <>>;
+exports.selfClosing = ;
+//// [two.jsx]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
+///
+/* @jsxRuntime automatic */
+var HelloWorld = function () { return Hello world
; };
+exports.HelloWorld = HelloWorld;
+exports.frag = <>>;
+exports.selfClosing = ;
+//// [three.jsx]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
+///
+/* @jsxRuntime classic */
+/* @jsxRuntime automatic */
+var HelloWorld = function () { return Hello world
; };
+exports.HelloWorld = HelloWorld;
+exports.frag = <>>;
+exports.selfClosing = ;
+//// [four.jsx]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
+///
+/* @jsxRuntime automatic */
+/* @jsxRuntime classic */
+var React = require("react");
+var HelloWorld = function () { return Hello world
; };
+exports.HelloWorld = HelloWorld;
+exports.frag = <>>;
+exports.selfClosing = ;
+//// [index.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.four = exports.three = exports.two = exports.one = void 0;
+exports.one = require("./one.js");
+exports.two = require("./two.js");
+exports.three = require("./three.js");
+exports.four = require("./four.js");
diff --git a/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).symbols b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).symbols
new file mode 100644
index 0000000000000..0060411a1a943
--- /dev/null
+++ b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).symbols
@@ -0,0 +1,95 @@
+//// [tests/cases/compiler/jsxRuntimePragma.ts] ////
+
+=== one.tsx ===
+///
+/* @jsxRuntime classic */
+import * as React from "react";
+>React : Symbol(React, Decl(one.tsx, 2, 6))
+
+export const HelloWorld = () => Hello world
;
+>HelloWorld : Symbol(HelloWorld, Decl(one.tsx, 3, 12))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+
+export const frag = <>>;
+>frag : Symbol(frag, Decl(one.tsx, 4, 12))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+
+export const selfClosing = ;
+>selfClosing : Symbol(selfClosing, Decl(one.tsx, 5, 12))
+>img : Symbol(JSX.IntrinsicElements.img, Decl(react16.d.ts, 2569, 114))
+>src : Symbol(src, Decl(one.tsx, 5, 31))
+
+=== two.tsx ===
+///
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+>HelloWorld : Symbol(HelloWorld, Decl(two.tsx, 2, 12))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+
+export const frag = <>>;
+>frag : Symbol(frag, Decl(two.tsx, 3, 12))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+
+export const selfClosing = ;
+>selfClosing : Symbol(selfClosing, Decl(two.tsx, 4, 12))
+>img : Symbol(JSX.IntrinsicElements.img, Decl(react16.d.ts, 2569, 114))
+>src : Symbol(src, Decl(two.tsx, 4, 31))
+
+=== three.tsx ===
+///
+/* @jsxRuntime classic */
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+>HelloWorld : Symbol(HelloWorld, Decl(three.tsx, 3, 12))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+
+export const frag = <>>;
+>frag : Symbol(frag, Decl(three.tsx, 4, 12))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+
+export const selfClosing = ;
+>selfClosing : Symbol(selfClosing, Decl(three.tsx, 5, 12))
+>img : Symbol(JSX.IntrinsicElements.img, Decl(react16.d.ts, 2569, 114))
+>src : Symbol(src, Decl(three.tsx, 5, 31))
+
+=== four.tsx ===
+///
+/* @jsxRuntime automatic */
+/* @jsxRuntime classic */
+import * as React from "react";
+>React : Symbol(React, Decl(four.tsx, 3, 6))
+
+export const HelloWorld = () => Hello world
;
+>HelloWorld : Symbol(HelloWorld, Decl(four.tsx, 4, 12))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react16.d.ts, 2556, 106))
+
+export const frag = <>>;
+>frag : Symbol(frag, Decl(four.tsx, 5, 12))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2546, 114))
+
+export const selfClosing = ;
+>selfClosing : Symbol(selfClosing, Decl(four.tsx, 6, 12))
+>img : Symbol(JSX.IntrinsicElements.img, Decl(react16.d.ts, 2569, 114))
+>src : Symbol(src, Decl(four.tsx, 6, 31))
+
+=== index.ts ===
+export * as one from "./one.js";
+>one : Symbol(one, Decl(index.ts, 0, 6))
+
+export * as two from "./two.js";
+>two : Symbol(two, Decl(index.ts, 1, 6))
+
+export * as three from "./three.js";
+>three : Symbol(three, Decl(index.ts, 2, 6))
+
+export * as four from "./four.js";
+>four : Symbol(four, Decl(index.ts, 3, 6))
+
diff --git a/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).types b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).types
new file mode 100644
index 0000000000000..87eb419fb5327
--- /dev/null
+++ b/tests/baselines/reference/jsxRuntimePragma(jsx=preserve).types
@@ -0,0 +1,183 @@
+//// [tests/cases/compiler/jsxRuntimePragma.ts] ////
+
+=== Performance Stats ===
+Assignability cache: 2,500
+Type Count: 5,000
+Instantiation count: 50,000
+Symbol count: 50,000
+
+=== one.tsx ===
+///
+/* @jsxRuntime classic */
+import * as React from "react";
+>React : typeof React
+> : ^^^^^^^^^^^^
+
+export const HelloWorld = () => Hello world
;
+>HelloWorld : () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>() => Hello world
: () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>Hello world
: JSX.Element
+> : ^^^^^^^^^^^
+>h1 : any
+> : ^^^
+>h1 : any
+> : ^^^
+
+export const frag = <>>;
+>frag : JSX.Element
+> : ^^^^^^^^^^^
+><>> : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>div : any
+> : ^^^
+>div : any
+> : ^^^
+
+export const selfClosing = ;
+>selfClosing : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>img : any
+> : ^^^
+>src : string
+> : ^^^^^^
+
+=== two.tsx ===
+///
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+>HelloWorld : () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>() => Hello world
: () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>Hello world
: JSX.Element
+> : ^^^^^^^^^^^
+>h1 : any
+> : ^^^
+>h1 : any
+> : ^^^
+
+export const frag = <>>;
+>frag : JSX.Element
+> : ^^^^^^^^^^^
+><>> : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>div : any
+> : ^^^
+>div : any
+> : ^^^
+
+export const selfClosing = ;
+>selfClosing : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>img : any
+> : ^^^
+>src : string
+> : ^^^^^^
+
+=== three.tsx ===
+///
+/* @jsxRuntime classic */
+/* @jsxRuntime automatic */
+export const HelloWorld = () => Hello world
;
+>HelloWorld : () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>() => Hello world
: () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>Hello world
: JSX.Element
+> : ^^^^^^^^^^^
+>h1 : any
+> : ^^^
+>h1 : any
+> : ^^^
+
+export const frag = <>>;
+>frag : JSX.Element
+> : ^^^^^^^^^^^
+><>> : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>div : any
+> : ^^^
+>div : any
+> : ^^^
+
+export const selfClosing = ;
+>selfClosing : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>img : any
+> : ^^^
+>src : string
+> : ^^^^^^
+
+=== four.tsx ===
+///
+/* @jsxRuntime automatic */
+/* @jsxRuntime classic */
+import * as React from "react";
+>React : typeof React
+> : ^^^^^^^^^^^^
+
+export const HelloWorld = () => Hello world
;
+>HelloWorld : () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>() => Hello world
: () => JSX.Element
+> : ^^^^^^^^^^^^^^^^^
+>Hello world
: JSX.Element
+> : ^^^^^^^^^^^
+>h1 : any
+> : ^^^
+>h1 : any
+> : ^^^
+
+export const frag = <>>;
+>frag : JSX.Element
+> : ^^^^^^^^^^^
+><>> : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>div : any
+> : ^^^
+>div : any
+> : ^^^
+
+export const selfClosing = ;
+>selfClosing : JSX.Element
+> : ^^^^^^^^^^^
+> : JSX.Element
+> : ^^^^^^^^^^^
+>img : any
+> : ^^^
+>src : string
+> : ^^^^^^
+
+=== index.ts ===
+export * as one from "./one.js";
+>one : typeof import("one")
+> : ^^^^^^^^^^^^^^^^^^^^
+
+export * as two from "./two.js";
+>two : typeof import("two")
+> : ^^^^^^^^^^^^^^^^^^^^
+
+export * as three from "./three.js";
+>three : typeof import("three")
+> : ^^^^^^^^^^^^^^^^^^^^^^
+
+export * as four from "./four.js";
+>four : typeof import("four")
+> : ^^^^^^^^^^^^^^^^^^^^^
+
diff --git a/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt b/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt
index b4fb215aaed6f..69e07e52360a5 100644
--- a/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt
+++ b/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx2.errors.txt
@@ -1,17 +1,14 @@
index.js(2,12): error TS17014: JSX fragment has no corresponding closing tag.
-index.js(2,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
index.js(2,13): error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
index.js(3,1): error TS1005: '' expected.
-==== index.js (4 errors) ====
+==== index.js (3 errors) ====
const x = "oops";
const y = + <> x;
~~~
!!! error TS17014: JSX fragment has no corresponding closing tag.
~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
- ~~
!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided.
diff --git a/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt b/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt
index 403885082355f..2c200912716c1 100644
--- a/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt
+++ b/tests/baselines/reference/parseUnaryExpressionNoTypeAssertionInJsx4.errors.txt
@@ -1,12 +1,11 @@
index.tsx(3,14): error TS17008: JSX element 'number' has no corresponding closing tag.
-index.tsx(4,13): error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
index.tsx(4,13): error TS17014: JSX fragment has no corresponding closing tag.
index.tsx(5,14): error TS1003: Identifier expected.
index.tsx(5,18): error TS1382: Unexpected token. Did you mean `{'>'}` or `>`?
index.tsx(6,1): error TS1005: '' expected.
-==== index.tsx (6 errors) ====
+==== index.tsx (5 errors) ====
const x = "oops";
const a = + x;
@@ -14,8 +13,6 @@ index.tsx(6,1): error TS1005: '' expected.
!!! error TS17008: JSX element 'number' has no corresponding closing tag.
const b = + <> x;
~~
-!!! error TS2879: Using JSX fragments requires fragment factory 'React' to be in scope, but it could not be found.
- ~~
!!! error TS17014: JSX fragment has no corresponding closing tag.
const c = + <1234> x;
~~~~
diff --git a/tests/cases/compiler/jsxFragmentFactoryReference.tsx b/tests/cases/compiler/jsxFragmentFactoryReference.tsx
new file mode 100644
index 0000000000000..99f2fc118de87
--- /dev/null
+++ b/tests/cases/compiler/jsxFragmentFactoryReference.tsx
@@ -0,0 +1,14 @@
+// @noTypesAndSymbols: true
+// @noEmit: true
+// @jsx: preserve, react, react-jsx, react-jsxdev, react-native
+// @strict: true
+// @skipLibCheck: true
+// @target: ES2017
+// @module: ESNext
+// @esModuleInterop: true
+
+export class LoggedOut {
+ content = () => (
+ <>>
+ )
+}
diff --git a/tests/cases/compiler/jsxRuntimePragma.ts b/tests/cases/compiler/jsxRuntimePragma.ts
index c3d1829b3861d..0a14e9503e79d 100644
--- a/tests/cases/compiler/jsxRuntimePragma.ts
+++ b/tests/cases/compiler/jsxRuntimePragma.ts
@@ -1,4 +1,4 @@
-// @jsx: react,react-jsx,react-jsxdev
+// @jsx: react,react-jsx,react-jsxdev,preserve
// @filename: one.tsx
///
/* @jsxRuntime classic */