The issue is:
Type 'PropsWithoutRef<Props> & { ref: ForwardedRef<Ref>; }' is not assignable to type 'IntrinsicAttributes & Props'.
Type 'PropsWithoutRef<Props> & { ref: ForwardedRef<Ref>; }' is not assignable to type 'Props'.
'PropsWithoutRef<Props> & { ref: ForwardedRef<Ref>; }' is assignable to the constraint of type 'Props', but 'Props' could be instantiated with a different subtype of constraint 'Record<string, unknown>'.(2322)
function compose<Props extends Record<string, unknown>, Ref>(
...hocs: Array<(component: ComponentType<Props>) => ComponentType<Props>>
): (
component: ComponentType<Props>
) => ForwardRefExoticComponent<PropsWithoutRef<Props> & RefAttributes<Ref>> {
return (component: ComponentType<Props>) => {
const WrappedComponent = forwardRef<Ref, Props>(
(props, ref: ForwardedRef<Ref>) => {
const ComposedComponent = hocs.reduceRight(
(wrapped, hoc) => hoc(wrapped),
component
);
return <ComposedComponent {...props} ref={ref} />;
}
);
WrappedComponent.displayName = `Composed(${
component.displayName || component.name || 'Component'
})`;
return WrappedComponent;
};
}