Skip to content

Commit d00d560

Browse files
committed
Fix implicitly typed functions with jsx: react-jsx
1 parent 61883cf commit d00d560

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ export function parseFromProgram(
259259
return (
260260
name === 'global.JSX.Element' ||
261261
name === 'React.ReactElement' ||
262-
name === 'React.JSX.Element'
262+
name === 'React.JSX.Element' ||
263+
name.endsWith('@types/react/jsx-runtime".JSX.Element') || // when `"jsx": "react-jsx"` in tsconfig
264+
name.endsWith('@types/react/jsx-dev-runtime".JSX.Element') // when `"jsx": "react-jsxdev"` in tsconfig
263265
);
264266
}
265267

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function Component(props: Props) {
2+
return <div {...props} />;
3+
}
4+
5+
interface Props {
6+
className?: string;
7+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"nodeType": "program",
3+
"body": [
4+
{
5+
"nodeType": "component",
6+
"name": "Component",
7+
"props": [
8+
{
9+
"nodeType": "prop",
10+
"name": "className",
11+
"propType": {
12+
"nodeType": "union",
13+
"types": [
14+
{
15+
"nodeType": "simpleType",
16+
"typeName": "undefined"
17+
},
18+
{
19+
"nodeType": "simpleType",
20+
"typeName": "string"
21+
}
22+
]
23+
},
24+
"optional": true,
25+
"filenames": {}
26+
}
27+
]
28+
}
29+
]
30+
}

0 commit comments

Comments
 (0)