Skip to content

[BUG] React OpenFeatureProvider types as JSX.Element conflicts in React 19 #1307

@andomain

Description

@andomain

Observed behavior

I have just upgraded a Typescript codebase to React 19 and observed the following TS error

'OpenFeatureProvider' cannot be used as a JSX component.
  Its type '({ client, domain, children, ...options }: ProviderProps) => Element' is not a valid JSX element type.
    Type '({ client, domain, children, ...options }: ProviderProps) => Element' is not assignable to type '(props: any) => ReactNode | Promise<ReactNode>'.
      Type 'Element' is not assignable to type 'ReactNode | Promise<ReactNode>'.
        Property 'children' is missing in type 'ReactElement<any, any>' but required in type 'ReactPortal'.

The React OpenFeatureProvider is typed to return a JSX.Element, in React 19 this is considered too narrow for a component return type (TS now expects all potential return types including a ReactPortal etc.)

I'd happily work on a PR to update the type signature for the provider but keen to hear thoughts regarding backwards compatibility etc. AFAIK ReactElement should be compatible with existing usage.

Expected Behavior

Able to use OpenFeatureProvider without TS errors

Steps to reproduce

In a React 19 Typescript project create a functional component that returns JSX with OpenFeatureProvider as the parent element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions