Skip to content

Render function's typescript type excludes valid react component types #1271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
trappar opened this issue Feb 1, 2024 · 0 comments · Fixed by #1272
Closed

Render function's typescript type excludes valid react component types #1271

trappar opened this issue Feb 1, 2024 · 0 comments · Fixed by #1272

Comments

@trappar
Copy link
Contributor

trappar commented Feb 1, 2024

  • @testing-library/react version: 14.2.0
  • Testing Framework and version: N/A
  • DOM Environment: N/A

Relevant code or config:

const MyValidComponent = () => "Components can return strings";

render(<MyValidComponent />)

Results in the following typescript error:

'MyValidComponent' cannot be used as a JSX component.
Its return type '"test" | Element | null' is not a valid JSX element.

Problem description:

The types for this package define render's ui property as ReactElement (here). This doesn't seem right since this excludes all kinds of valid react component return types.

Suggested solution:

render's ui property should be typed as ReactNode instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant