diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce0291367b510..858acf404c329 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29882,7 +29882,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // #38720/60122, allow null as jsxFragmentFactory let jsxFactorySym: Symbol | undefined; if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, compilerOptions.jsx === JsxEmit.Preserve ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, jsxFactoryRefErr, /*isUse*/ true); + jsxFactorySym = resolveName( + jsxFactoryLocation, + jsxFactoryNamespace, + (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, + jsxFactoryRefErr, + /*isUse*/ true, + ); } if (jsxFactorySym) { @@ -29901,7 +29907,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const file = getSourceFileOfNode(node); const localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, compilerOptions.jsx === JsxEmit.Preserve ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, jsxFactoryRefErr, /*isUse*/ true); + resolveName( + jsxFactoryLocation, + localJsxNamespace, + (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, + jsxFactoryRefErr, + /*isUse*/ true, + ); } } } @@ -36655,7 +36667,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { 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 ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, /*nameNotFoundMessage*/ jsxFactoryRefErr, /*isUse*/ true); + resolveName( + node, + jsxFragmentFactoryName, + (compilerOptions.jsx === JsxEmit.Preserve || compilerOptions.jsx === JsxEmit.ReactNative) ? SymbolFlags.Value & ~SymbolFlags.Enum : SymbolFlags.Value, + /*nameNotFoundMessage*/ jsxFactoryRefErr, + /*isUse*/ true, + ); if (jsxFactorySymbol === undefined) return sourceFileLinks.jsxFragmentType = errorType; if (jsxFactorySymbol.escapedName === ReactNames.Fragment) return sourceFileLinks.jsxFragmentType = getTypeOfSymbol(jsxFactorySymbol); diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).js b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).js new file mode 100644 index 0000000000000..29e499dbf98ea --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +//// [jsxFragReactReferenceErrors.tsx] +/// +/// +export function Component(){ + +return <> + +} + +//// [jsxFragReactReferenceErrors.jsx] +/// +/// +export function Component() { + return <> + ; +} diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).symbols b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).symbols new file mode 100644 index 0000000000000..df63a975364b0 --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +=== jsxFragReactReferenceErrors.tsx === +/// +/// +export function Component(){ +>Component : Symbol(Component, Decl(jsxFragReactReferenceErrors.tsx, 0, 0)) + +return <> + +} diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).types b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).types new file mode 100644 index 0000000000000..64a3cab0824cf --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=preserve).types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +=== jsxFragReactReferenceErrors.tsx === +/// +/// +export function Component(){ +>Component : () => JSX.Element +> : ^^^^^^^^^^^^^^^^^ + +return <> +><> : JSX.Element +> : ^^^^^^^^^^^ + + +} diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).js b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).js new file mode 100644 index 0000000000000..9ccb21875c4e4 --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +//// [jsxFragReactReferenceErrors.tsx] +/// +/// +export function Component(){ + +return <> + +} + +//// [jsxFragReactReferenceErrors.js] +/// +/// +export function Component() { + return <> + ; +} diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).symbols b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).symbols new file mode 100644 index 0000000000000..df63a975364b0 --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).symbols @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +=== jsxFragReactReferenceErrors.tsx === +/// +/// +export function Component(){ +>Component : Symbol(Component, Decl(jsxFragReactReferenceErrors.tsx, 0, 0)) + +return <> + +} diff --git a/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).types b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).types new file mode 100644 index 0000000000000..64a3cab0824cf --- /dev/null +++ b/tests/baselines/reference/jsxFragReactReferenceErrors(jsx=react-native).types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] //// + +=== jsxFragReactReferenceErrors.tsx === +/// +/// +export function Component(){ +>Component : () => JSX.Element +> : ^^^^^^^^^^^^^^^^^ + +return <> +><> : JSX.Element +> : ^^^^^^^^^^^ + + +} diff --git a/tests/cases/compiler/jsxFragReactReferenceErrors.tsx b/tests/cases/compiler/jsxFragReactReferenceErrors.tsx new file mode 100644 index 0000000000000..92f4725d51bc3 --- /dev/null +++ b/tests/cases/compiler/jsxFragReactReferenceErrors.tsx @@ -0,0 +1,14 @@ +// @jsx: react-native, preserve +// @strict: true +// @skipLibCheck: true +// @target: ES2017 +// @module: ESNext +// @esModuleInterop: true + +/// +/// +export function Component(){ + +return <> + +} \ No newline at end of file