Here is my code, but it won't pass typescript validation
import * as React from "react";
export function makeWrapperFn<P, C extends React.ComponentType >(Comp: C, baseProps = {} ) {
return (props: Partial<P> = {} ) => {
// I want this returned function can override the props
return (<Comp {...baseProps} {...(props)} />);
// Comp is problem here
};
}
The error message is:
Type 'Partial<P>' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<C, { children?: ReactNode; }>'.
Type 'Partial<P>' is not assignable to type 'LibraryManagedAttributes<C, { children?: ReactNode; }>'.ts(2322)
So how do I make this wrapper function maker that with typescript constraint?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…