Skip to content

forwardRef and memo examples don't work with Typescript 5.1 #12

@Schiavi

Description

@Schiavi

Hello!

I tried to update our typescript to 5.1 and now we are seeing errors on our usage of PolymorphicForwardRefExoticComponent. The same error also happens with PolymorphicMemoExoticComponent

It also errors on playground using the example from the package: TS Playground with Error

Full Error is:

Type 'ForwardRefExoticComponent<Omit<Omit<SVGProps<SVGSymbolElement>, "ref"> | Omit<DetailedHTMLProps<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>, "ref"> | ... 121 more ... | Omit<...>, "as" | "color"> & HeadingOwnProps & { ...; } & RefAttributes<...>>' is not assignable to type 'PolymorphicForwardRefExoticComponent<HeadingOwnProps, "h2">'.
  Type 'ForwardRefExoticComponent<Omit<Omit<SVGProps<SVGSymbolElement>, "ref"> | Omit<DetailedHTMLProps<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>, "ref"> | ... 121 more ... | Omit<...>, "as" | "color"> & HeadingOwnProps & { ...; } & RefAttributes<...>>' is not assignable to type '<InstanceT extends ElementType<any> = "h2">(props: PolymorphicPropsWithRef<HeadingOwnProps, InstanceT>) => ReactElement<any, string | JSXElementConstructor<...>> | null'.
    Type 'ReactNode' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | null'.
      Type 'undefined' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | null'.

my lib versions are:
Typescript: 5.1.3
@types/react: 18.2.14
@types/react-dom: 18.2.6

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions