Render function's typescript type excludes valid react component types
trappar opened this issue · comments
@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.