I'm trying to create a HOC in a React Native app, but I'm having issues getting the definitions to work.
interface IWithApolloClientComponentProps { apolloClient: ApolloClient<any>;}export function withApolloClient< P extends IWithApolloClientComponentProps, R = Omit<P, keyof IWithApolloClientComponentProps>>( Component: React.ComponentType<P>): React.ComponentType<R> { return function BoundComponent(props: R) { return <ApolloConsumer>{client => <Component {...props} apolloClient={client} />} . </ApolloConsumer>; };}
My VSCode keeps giving the following error:
Type 'R & { apolloClient: ApolloClient<object>; }' is not assignable to type 'IntrinsicAttributes & P & { children?: ReactNode; }'. Type 'R & { apolloClient: ApolloClient<object>; }' is not assignable to type 'P'.'R & { apolloClient: ApolloClient<object>; }' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'IWithApolloClientComponentProps'.ts(2322)
Is anyone seeing something I'm doing terribly wrong here?