title: Why is type not assignable to generic type
body: <p>I'm trying to build and type a HOC which just wraps a component in an ApolloProvider. I would like to be able to forward the ref on to the wrapped component. However, when I try and pass props along in the forwardRef component I'm getting type errors</p>
  
  <p>Somewhere along my research spree I stumbled upon an answer that talked about generics being the issue. </p>
  
  <pre><code>const withProvider = function&lt;P&gt;(WrappedComponent: React.ComponentClass&lt;P&gt;) {
  
    type Props = P &amp; { forwardedRef?: React.Ref&lt;any&gt; }
  
    class WithProvider extends React.Component&lt;Props&gt; {
      render() {
        const { forwardedRef, ...props } = this.props
        return (
          &lt;ApolloProvider client={client}&gt;
            &lt;WrappedComponent {...props} ref={forwardedRef} /&gt;
          &lt;/ApolloProvider&gt;
        )
      }
    }
  
    hoistNonReactStatics(WithProvider, WrappedComponent)
  
    return React.forwardRef((props, ref) =&gt; (
      &lt;WithProvider {...props} forwardedRef={ref} /&gt;
    ))
  }
  </code></pre>
  
  <p>Gives me the error:</p>
  
  <pre><code>
  Type '{ forwardedRef: string | ((instance: {} | null) =&gt; any) | RefObject&lt;{}&gt; | undefined; children?: ReactNode; }' is not assignable to type 'Readonly&lt;Props&gt;'
  
  </code></pre>
  
  <p>To me these should match up and the former should be assignable to the latter. The only thing I can think of is that <code>Readonly&lt;Props&gt;</code> contains a generic.</p>
  
  <p>Can someone point me in the right direction?</p>