mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix missing react error with fragments in react-native (#60615)
This commit is contained in:
parent
ee0e08bd96
commit
96410eb655
@ -30018,7 +30018,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) {
|
||||
@ -30037,7 +30043,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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36825,7 +36837,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);
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
//// [jsxFragReactReferenceErrors.tsx]
|
||||
/// <reference path="/.lib/react18/react18.d.ts" />
|
||||
/// <reference path="/.lib/react18/global.d.ts" />
|
||||
export function Component(){
|
||||
|
||||
return <>
|
||||
</>
|
||||
}
|
||||
|
||||
//// [jsxFragReactReferenceErrors.jsx]
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component() {
|
||||
return <>
|
||||
</>;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
=== jsxFragReactReferenceErrors.tsx ===
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component(){
|
||||
>Component : Symbol(Component, Decl(jsxFragReactReferenceErrors.tsx, 0, 0))
|
||||
|
||||
return <>
|
||||
</>
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
=== jsxFragReactReferenceErrors.tsx ===
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component(){
|
||||
>Component : () => JSX.Element
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
|
||||
return <>
|
||||
><> </> : JSX.Element
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
</>
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
//// [jsxFragReactReferenceErrors.tsx]
|
||||
/// <reference path="/.lib/react18/react18.d.ts" />
|
||||
/// <reference path="/.lib/react18/global.d.ts" />
|
||||
export function Component(){
|
||||
|
||||
return <>
|
||||
</>
|
||||
}
|
||||
|
||||
//// [jsxFragReactReferenceErrors.js]
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component() {
|
||||
return <>
|
||||
</>;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
=== jsxFragReactReferenceErrors.tsx ===
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component(){
|
||||
>Component : Symbol(Component, Decl(jsxFragReactReferenceErrors.tsx, 0, 0))
|
||||
|
||||
return <>
|
||||
</>
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
//// [tests/cases/compiler/jsxFragReactReferenceErrors.tsx] ////
|
||||
|
||||
=== jsxFragReactReferenceErrors.tsx ===
|
||||
/// <reference path="react18/react18.d.ts" />
|
||||
/// <reference path="react18/global.d.ts" />
|
||||
export function Component(){
|
||||
>Component : () => JSX.Element
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
|
||||
return <>
|
||||
><> </> : JSX.Element
|
||||
> : ^^^^^^^^^^^
|
||||
|
||||
</>
|
||||
}
|
||||
14
tests/cases/compiler/jsxFragReactReferenceErrors.tsx
Normal file
14
tests/cases/compiler/jsxFragReactReferenceErrors.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
// @jsx: react-native, preserve
|
||||
// @strict: true
|
||||
// @skipLibCheck: true
|
||||
// @target: ES2017
|
||||
// @module: ESNext
|
||||
// @esModuleInterop: true
|
||||
|
||||
/// <reference path="/.lib/react18/react18.d.ts" />
|
||||
/// <reference path="/.lib/react18/global.d.ts" />
|
||||
export function Component(){
|
||||
|
||||
return <>
|
||||
</>
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user