Skip to content

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

Closed
@trappar

Description

@trappar
  • @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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions