Remove reference not found errors from jsx: preserve (#60687)

This commit is contained in:
Isabel Duan 2024-12-09 10:38:37 -08:00 committed by GitHub
parent 421f5c5458
commit 3d2b8f33d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 435 additions and 30 deletions

View File

@ -30015,6 +30015,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;
@ -30022,7 +30023,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,
);
@ -30048,7 +30049,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,
);
@ -36841,15 +36842,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;
// #38720/60122, allow null as jsxFragmentFactory
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,
);

View File

@ -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.
)
}

View File

@ -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?
)
}

View File

@ -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?
)
}

View File

@ -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) ====
/// <reference path="/.lib/react16.d.ts" />
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.
<p></p>
text
<div className="foo"></div>

View File

@ -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) ====
/// <reference path="/.lib/react16.d.ts" />
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.
<p></p>
text
<div className="foo"></div>

View File

@ -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) ====
/// <reference path="/.lib/react16.d.ts" />
/* @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.
<p></p>
text
<div className="foo"></div>

View File

@ -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) ====
/// <reference path="/.lib/react16.d.ts" />
/* @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.
<p></p>
text
<div className="foo"></div>

View File

@ -0,0 +1,88 @@
//// [tests/cases/compiler/jsxRuntimePragma.ts] ////
//// [one.tsx]
/// <reference path="/.lib/react16.d.ts" />
/* @jsxRuntime classic */
import * as React from "react";
export const HelloWorld = () => <h1>Hello world</h1>;
export const frag = <><div></div></>;
export const selfClosing = <img src="./image.png" />;
//// [two.tsx]
/// <reference path="/.lib/react16.d.ts" />
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
export const frag = <><div></div></>;
export const selfClosing = <img src="./image.png" />;
//// [three.tsx]
/// <reference path="/.lib/react16.d.ts" />
/* @jsxRuntime classic */
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
export const frag = <><div></div></>;
export const selfClosing = <img src="./image.png" />;
//// [four.tsx]
/// <reference path="/.lib/react16.d.ts" />
/* @jsxRuntime automatic */
/* @jsxRuntime classic */
import * as React from "react";
export const HelloWorld = () => <h1>Hello world</h1>;
export const frag = <><div></div></>;
export const selfClosing = <img src="./image.png" />;
//// [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;
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
var React = require("react");
var HelloWorld = function () { return <h1>Hello world</h1>; };
exports.HelloWorld = HelloWorld;
exports.frag = <><div></div></>;
exports.selfClosing = <img src="./image.png"/>;
//// [two.jsx]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
var HelloWorld = function () { return <h1>Hello world</h1>; };
exports.HelloWorld = HelloWorld;
exports.frag = <><div></div></>;
exports.selfClosing = <img src="./image.png"/>;
//// [three.jsx]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
/* @jsxRuntime automatic */
var HelloWorld = function () { return <h1>Hello world</h1>; };
exports.HelloWorld = HelloWorld;
exports.frag = <><div></div></>;
exports.selfClosing = <img src="./image.png"/>;
//// [four.jsx]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selfClosing = exports.frag = exports.HelloWorld = void 0;
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
/* @jsxRuntime classic */
var React = require("react");
var HelloWorld = function () { return <h1>Hello world</h1>; };
exports.HelloWorld = HelloWorld;
exports.frag = <><div></div></>;
exports.selfClosing = <img src="./image.png"/>;
//// [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");

View File

@ -0,0 +1,95 @@
//// [tests/cases/compiler/jsxRuntimePragma.ts] ////
=== one.tsx ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
import * as React from "react";
>React : Symbol(React, Decl(one.tsx, 2, 6))
export const HelloWorld = () => <h1>Hello world</h1>;
>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 = <><div></div></>;
>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 = <img src="./image.png" />;
>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 ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
>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 = <><div></div></>;
>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 = <img src="./image.png" />;
>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 ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
>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 = <><div></div></>;
>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 = <img src="./image.png" />;
>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 ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
/* @jsxRuntime classic */
import * as React from "react";
>React : Symbol(React, Decl(four.tsx, 3, 6))
export const HelloWorld = () => <h1>Hello world</h1>;
>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 = <><div></div></>;
>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 = <img src="./image.png" />;
>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))

View File

@ -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 ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
import * as React from "react";
>React : typeof React
> : ^^^^^^^^^^^^
export const HelloWorld = () => <h1>Hello world</h1>;
>HelloWorld : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
>() => <h1>Hello world</h1> : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
><h1>Hello world</h1> : JSX.Element
> : ^^^^^^^^^^^
>h1 : any
> : ^^^
>h1 : any
> : ^^^
export const frag = <><div></div></>;
>frag : JSX.Element
> : ^^^^^^^^^^^
><><div></div></> : JSX.Element
> : ^^^^^^^^^^^
><div></div> : JSX.Element
> : ^^^^^^^^^^^
>div : any
> : ^^^
>div : any
> : ^^^
export const selfClosing = <img src="./image.png" />;
>selfClosing : JSX.Element
> : ^^^^^^^^^^^
><img src="./image.png" /> : JSX.Element
> : ^^^^^^^^^^^
>img : any
> : ^^^
>src : string
> : ^^^^^^
=== two.tsx ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
>HelloWorld : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
>() => <h1>Hello world</h1> : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
><h1>Hello world</h1> : JSX.Element
> : ^^^^^^^^^^^
>h1 : any
> : ^^^
>h1 : any
> : ^^^
export const frag = <><div></div></>;
>frag : JSX.Element
> : ^^^^^^^^^^^
><><div></div></> : JSX.Element
> : ^^^^^^^^^^^
><div></div> : JSX.Element
> : ^^^^^^^^^^^
>div : any
> : ^^^
>div : any
> : ^^^
export const selfClosing = <img src="./image.png" />;
>selfClosing : JSX.Element
> : ^^^^^^^^^^^
><img src="./image.png" /> : JSX.Element
> : ^^^^^^^^^^^
>img : any
> : ^^^
>src : string
> : ^^^^^^
=== three.tsx ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime classic */
/* @jsxRuntime automatic */
export const HelloWorld = () => <h1>Hello world</h1>;
>HelloWorld : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
>() => <h1>Hello world</h1> : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
><h1>Hello world</h1> : JSX.Element
> : ^^^^^^^^^^^
>h1 : any
> : ^^^
>h1 : any
> : ^^^
export const frag = <><div></div></>;
>frag : JSX.Element
> : ^^^^^^^^^^^
><><div></div></> : JSX.Element
> : ^^^^^^^^^^^
><div></div> : JSX.Element
> : ^^^^^^^^^^^
>div : any
> : ^^^
>div : any
> : ^^^
export const selfClosing = <img src="./image.png" />;
>selfClosing : JSX.Element
> : ^^^^^^^^^^^
><img src="./image.png" /> : JSX.Element
> : ^^^^^^^^^^^
>img : any
> : ^^^
>src : string
> : ^^^^^^
=== four.tsx ===
/// <reference path="react16.d.ts" />
/* @jsxRuntime automatic */
/* @jsxRuntime classic */
import * as React from "react";
>React : typeof React
> : ^^^^^^^^^^^^
export const HelloWorld = () => <h1>Hello world</h1>;
>HelloWorld : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
>() => <h1>Hello world</h1> : () => JSX.Element
> : ^^^^^^^^^^^^^^^^^
><h1>Hello world</h1> : JSX.Element
> : ^^^^^^^^^^^
>h1 : any
> : ^^^
>h1 : any
> : ^^^
export const frag = <><div></div></>;
>frag : JSX.Element
> : ^^^^^^^^^^^
><><div></div></> : JSX.Element
> : ^^^^^^^^^^^
><div></div> : JSX.Element
> : ^^^^^^^^^^^
>div : any
> : ^^^
>div : any
> : ^^^
export const selfClosing = <img src="./image.png" />;
>selfClosing : JSX.Element
> : ^^^^^^^^^^^
><img src="./image.png" /> : 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")
> : ^^^^^^^^^^^^^^^^^^^^^

View File

@ -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.

View File

@ -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 `&gt;`?
index.tsx(6,1): error TS1005: '</' expected.
==== index.tsx (6 errors) ====
==== index.tsx (5 errors) ====
const x = "oops";
const a = + <number> 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;
~~~~

View File

@ -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 = () => (
<></>
)
}

View File

@ -1,4 +1,4 @@
// @jsx: react,react-jsx,react-jsxdev
// @jsx: react,react-jsx,react-jsxdev,preserve
// @filename: one.tsx
/// <reference path="/.lib/react16.d.ts" />
/* @jsxRuntime classic */