title: Create a typescript function returning react component class
body: <p>I need to create an utility function, which will be returning one of react component classes (not instances) depending on some condition. So the return type of the function should be generic (React.PureComponent)</p>
  
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  class FooOne extends React.PureComponent {
      render(): React.ReactElement {
          return null;
      }
  }
  class FooTwo extends React.PureComponent {
      render(): React.ReactElement {
          return null;
      }
  }
  function getFooClass(condition: boolean): typeof React.PureComponent {
      return condition ? FooOne : FooTwo;
  }
  const SomeFooClass = getFooClass(true);
  const instance: React.PureComponent = new SomeFooClass();
  </code></pre>
  
  <p>code above is tended to be working (I still not understand why I need to use <strong>typeof React.PureComponent</strong> as return type for getFooClass, this was found experimentally), 
  but typescript generates the following error for getFooClass:</p>
  
  <pre><code>Type 'typeof FooOne' is not assignable to type 'typeof PureComponent'.
    Construct signature return types 'FooOne' and 'PureComponent&lt;P, S&gt;' are incompatible.
      The types of 'props' are incompatible between these types.
        Type 'Readonly&lt;{ children?: ReactNode; }&gt; &amp; Readonly&lt;{}&gt;' is not assignable to type 'Readonly&lt;{ children?: ReactNode; }&gt; &amp; Readonly&lt;P&gt;'.
          Type 'Readonly&lt;{ children?: ReactNode; }&gt; &amp; Readonly&lt;{}&gt;' is not assignable to type 'Readonly&lt;P&gt;'.
  </code></pre>
  
  <p>Maybe this is kind of typescript bug or limitation?</p>