Skip to content

Commit bbcd5ea

Browse files
authored
[code-infra] Allow more permissive Element types (#48186)
1 parent c4bf80f commit bbcd5ea

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

packages-internal/api-docs-builder/src/utils/getPropsFromComponentNode.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ function isTypeJSXElementLike(type: ts.Type, project: TypeScriptProject): boolea
2323
if (symbol) {
2424
const name = project.checker.getFullyQualifiedName(symbol);
2525
return (
26-
// Remove once global JSX namespace is no longer used by React
27-
name === 'global.JSX.Element' ||
28-
name === 'React.JSX.Element' ||
29-
name === 'React.ReactElement' ||
30-
name === 'React.ReactNode'
26+
// Some types are resolved to paths like: "/Users/.../node_modules/@types/react/jsx-runtime".JSX.Element
27+
name.endsWith('.JSX.Element') || name.endsWith('.ReactElement') || name.endsWith('.ReactNode')
3128
);
3229
}
3330

packages-internal/docs-utils/src/getPropsFromComponentNode.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ function isTypeJSXElementLike(type: ts.Type, project: TypeScriptProject): boolea
2323
if (symbol) {
2424
const name = project.checker.getFullyQualifiedName(symbol);
2525
return (
26-
// Remove once global JSX namespace is no longer used by React
27-
name === 'global.JSX.Element' ||
28-
name === 'React.JSX.Element' ||
29-
name === 'React.ReactElement' ||
30-
name === 'React.ReactNode'
26+
// Some types are resolved to paths like: "/Users/.../node_modules/@types/react/jsx-runtime".JSX.Element
27+
name.endsWith('.JSX.Element') || name.endsWith('.ReactElement') || name.endsWith('.ReactNode')
3128
);
3229
}
3330

0 commit comments

Comments
 (0)