title: TypeScript conditional types: Extract component props type from react component
body: <p>Using TypeScript 2.8 new conditional generic type feature, is it possible to extract the <code>TProps</code> of a <code>React.ComponentType&lt;TProps&gt;</code> component? I want a type that can <strong>either</strong> work on the <code>ComponentType</code> or the <code>TProps</code> itself, so you can - as a developer - pass either of both:</p>
  
  <p>For example:</p>
  
  <pre><code>interface TestProps {
      foo: string;
  }
  
  const TestComponent extends React.Component&lt;TestProps, {}&gt; {
      render() { return null; }
  }
  
  // now I need to create a type using conditional types so that
  // I can pass either the component or the props and always get the 
  // TProps type back
  type ExtractProps&lt;TComponentOrTProps&gt; = /* ?? how to do it? */
  
  type a = ExtractProps&lt;TestComponent&gt; // type a should be TestProps
  type b = ExtractProps&lt;TestProps&gt;     // type b should also be TestProps
  </code></pre>
  
  <p>Is this possible, and can anybody provide a solution?</p>