error TS2769: No overload matches this call.
Overload 1 of 2, '(props: Omit<Omit<Pick<DetailedHTMLProps<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "key" | keyof DetailsHTMLAttributes<...>> & { ...; } & SxProp, never> & Partial<...>, "theme"> & { ...; } & { ...; }): ReactElement<...>', gave the following error.
Type '{ children: (false | Element | undefined)[]; open: boolean; onToggle: (e: SyntheticEvent<HTMLElement, Event>) => void; sx: { ':first-child summary': { ...; }; ':last-child summary': { ...; }; }; ref: RefObject<...>; }' is not assignable to type 'Omit<Omit<Pick<DetailedHTMLProps<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "key" | keyof DetailsHTMLAttributes<...>> & { ...; } & SxProp, never> & Partial<...>, "theme">'.
Types of property 'ref' are incompatible.
Type 'RefObject<HTMLElement>' is not assignable to type '((instance: HTMLDetailsElement | null) => void) | RefObject<HTMLDetailsElement> | null | undefined'.
Type 'RefObject<HTMLElement>' is not assignable to type 'RefObject<HTMLDetailsElement>'.
Property 'open' is missing in type 'HTMLElement' but required in type 'HTMLDetailsElement'.
Overload 2 of 2, '(props: StyledComponentPropsWithAs<"details", any, SxProp, never, "details", "details">): ReactElement<StyledComponentPropsWithAs<"details", any, SxProp, never, "details", "details">, string | JSXElementConstructor<...>>', gave the following error.
Type '{ children: (false | Element | undefined)[]; open: boolean; onToggle: (e: SyntheticEvent<HTMLElement, Event>) => void; sx: { ':first-child summary': { ...; }; ':last-child summary': { ...; }; }; ref: RefObject<...>; }' is not assignable to type 'Omit<Omit<Pick<DetailedHTMLProps<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>, "key" | keyof DetailsHTMLAttributes<...>> & { ...; } & SxProp, never> & Partial<...>, "theme">'.
Types of property 'ref' are incompatible.
Type 'RefObject<HTMLElement>' is not assignable to type '((instance: HTMLDetailsElement | null) => void) | RefObject<HTMLDetailsElement> | null | undefined'.
Description
With React 18, the
refvalue fromuseDetailsis not compatible with therefprop ofDetails.I think the main issue is that the default ref created in the hook is of type
HTMLElement, where theDetailref knows it should be of typeHTMLDetailsElementRelates to #2536
Steps to reproduce
useDetailsandDetailsVersion
v35.14.2
Browser
No response