title: Writing declaration d.ts file for existing HOC
body: <p>I'm having problem with writing a <code>d.ts</code> file for a HOC component:
  <code>with-apollo-client.js</code> wraps an component to inject a prop in. It is something like this:</p>
  
  <pre><code>export default App =&gt; {
    return class Apollo extends React.Component{
      render(){
         // code to get apolloClient variable omitted
  
         &lt;Apollo client={apolloClient}&gt;
      }
    }
  }
  </code></pre>
  
  <p>To use it, we just do:</p>
  
  <pre><code>import withApolloClient from './with-apollo-client'
  ...
  export default withApolloClient(App)
  </code></pre>
  
  <p>And in <code>with-apollo-client.d.ts</code></p>
  
  <pre><code>import { ApolloClient } from 'apollo-boost';
  
  export interface WithApolloClient {
      apolloClient: ApolloClient&lt;any&gt;;
  }
  
  export default &lt;P extends WithApolloClient&gt;(App: React.ComponentType&lt;P&gt;) =&gt; {
      return class Apollo extends React.Component&lt;P&gt; {};
  };
  </code></pre>
  
  <p>And TS is complaining:</p>
  
  <pre><code>`Type '{ id: string; }' is not assignable to type 'Readonly&lt;Props&gt;'.
    Property 'apolloClient' is missing in type '{ id: string; }'.`
  </code></pre>