Skip to content

Commit 03db8ff

Browse files
authored
fix(3893): fix missing JSX runtime import (#3915)
1 parent 105910f commit 03db8ff

6 files changed

Lines changed: 39 additions & 1 deletion

File tree

internal/ast/parseoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func walkTreeForJSXTags(node *Node) *Node {
137137
if node.SubtreeFacts()&SubtreeContainsJsx == 0 {
138138
return false
139139
}
140-
if IsJsxOpeningElement(node) || IsJsxFragment(node) {
140+
if IsJsxOpeningLikeElement(node) || IsJsxFragment(node) {
141141
found = node
142142
return true
143143
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
a.tsx(1,13): error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
2+
a.tsx(1,14): error TS2552: Cannot find name 'App'. Did you mean 'app'?
3+
4+
5+
==== a.tsx (2 errors) ====
6+
const app = <App />;
7+
~~~~~~~
8+
!!! error TS2875: This JSX tag requires the module path 'react/jsx-runtime' to exist, but none could be found. Make sure you have types for the appropriate package installed.
9+
~~~
10+
!!! error TS2552: Cannot find name 'App'. Did you mean 'app'?
11+
!!! related TS2728 a.tsx:1:7: 'app' is declared here.
12+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [tests/cases/compiler/emitReactJsxSelfClosingElement.tsx] ////
2+
3+
//// [a.tsx]
4+
const app = <App />;
5+
6+
7+
//// [a.js]
8+
import { jsx as _jsx } from "react/jsx-runtime";
9+
const app = _jsx(App, {});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [tests/cases/compiler/emitReactJsxSelfClosingElement.tsx] ////
2+
3+
=== a.tsx ===
4+
const app = <App />;
5+
>app : Symbol(app, Decl(a.tsx, 0, 5))
6+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [tests/cases/compiler/emitReactJsxSelfClosingElement.tsx] ////
2+
3+
=== a.tsx ===
4+
const app = <App />;
5+
>app : any
6+
><App /> : any
7+
>App : any
8+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @jsx: react-jsx
2+
// @filename: a.tsx
3+
const app = <App />;

0 commit comments

Comments
 (0)