title: Wrapping react-redux's connect function in TypeScript results in compilation error
body: <p>I'm trying to wrap react-redux's <code>connect</code> function into a helper function for a test utility.</p>
  
  <p>Below is a simplified example:</p>
  
  <pre class="lang-js prettyprint-override"><code>interface IProps {
    number: number
  }
  
  class NumberDisplay extends React.PureComponent&lt;IProps&gt; {
    render() {
      return `${this.props.number}`
    }
  }
  
  function mapStateToProps(state: any) {
    return {number: 1}
  }
  </code></pre>
  
  <p>The following works as expected:</p>
  
  <pre class="lang-js prettyprint-override"><code>const ConnectedNumberDisplay1 = connect(mapStateToProps)(NumberDisplay)
  export const display1 = &lt;ConnectedNumberDisplay1 /&gt;
  </code></pre>
  
  <p>and it provides helpful type checks: if <code>number</code> is never set, the compilation will fail.</p>
  
  <p>My wrap function looks like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>function wrap&lt;StateProps, ComponentProps&gt;(
    mapStateToProps: (state: any) =&gt; StateProps,
    Component: React.ComponentType&lt;ComponentProps&gt;
  ) {
    return connect(mapStateToProps)(Component)
                                 // ^^^^^^^^^ Error happens here
  }
  
  const ConnectedNumberDisplay2 = conn(mapStateToProps, NumberDisplay)
  export const display2 = &lt;ConnectedNumberDisplay2 /&gt;
  </code></pre>
  
  <p>This is the error:</p>
  
  <pre><code>Argument of type 'ComponentType&lt;ComponentProps&gt;' is not assignable to parameter of type 'ComponentType&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;&gt;'.
    Type 'ComponentClass&lt;ComponentProps, any&gt;' is not assignable to type 'ComponentType&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;&gt;'.
      Type 'ComponentClass&lt;ComponentProps, any&gt;' is not assignable to type 'ComponentClass&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;, any&gt;'.
        Types of property 'propTypes' are incompatible.
          Type 'WeakValidationMap&lt;ComponentProps&gt; | undefined' is not assignable to type 'WeakValidationMap&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;&gt; | undefined'.
            Type 'WeakValidationMap&lt;ComponentProps&gt;' is not assignable to type 'WeakValidationMap&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;&gt;'.
              Type '(null extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : undefined extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : Validator&lt;ComponentProps[K]&gt;) | undefined' is not assignable to type '(null extends Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] ? Validator&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] | null | undefined&gt; : undefined extends Matching&lt;...&gt;[K] ? Validator&lt;...&gt; : Validator&lt;...&gt;) | undefined'.
                Type 'null extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : undefined extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : Validator&lt;ComponentProps[K]&gt;' is not assignable to type '(null extends Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] ? Validator&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] | null | undefined&gt; : undefined extends Matching&lt;...&gt;[K] ? Validator&lt;...&gt; : Validator&lt;...&gt;) | undefined'.
                  Type 'Validator&lt;ComponentProps[K] | null | undefined&gt; | (undefined extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : Validator&lt;ComponentProps[K]&gt;)' is not assignable to type '(null extends Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] ? Validator&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] | null | undefined&gt; : undefined extends Matching&lt;...&gt;[K] ? Validator&lt;...&gt; : Validator&lt;...&gt;) | undefined'.
                    Type 'Validator&lt;ComponentProps[K] | null | undefined&gt;' is not assignable to type 'null extends Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] ? Validator&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] | null | undefined&gt; : undefined extends Matching&lt;...&gt;[K] ? Validator&lt;...&gt; : Validator&lt;...&gt;'.
                      Type 'null extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : undefined extends ComponentProps[K] ? Validator&lt;ComponentProps[K] | null | undefined&gt; : Validator&lt;ComponentProps[K]&gt;' is not assignable to type 'null extends Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] ? Validator&lt;Matching&lt;StateProps &amp; DispatchProp&lt;AnyAction&gt;, ComponentProps&gt;[K] | null | undefined&gt; : undefined extends Matching&lt;...&gt;[K] ? Validator&lt;...&gt; : Validator&lt;...&gt;'.
  
  </code></pre>
  
  <p>As a temporary workaround, I'm using something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>function wrap&lt;StateProps, ComponentProps&gt;(
    mapStateToProps: (state: any) =&gt; StateProps,
    Component: React.ComponentType&lt;ComponentProps&gt;,
  ): React.ComponentType&lt;
    Omit&lt;ComponentProps, keyof StateProps &amp; keyof ComponentProps&gt;&gt; {
    return connect(mapStateToProps)(Component as any) as any
  </code></pre>
  
  <p>But I'd prefer not to use <code>any</code> if possible. I'm not sure what I'm missing here. Any help is appreciated!</p>