<p dir="auto"><strong>TypeScript Version:</strong> 1.8.7</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function make_component&lt;A, B extends A&gt;(arg: () =&gt; B) {
}

h&lt;{x: string}&gt;(() =&gt; {
    return {
        x: &quot;hello&quot;,
        y: 10,
    };
});"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">make_component</span><span class="pl-c1">&lt;</span><span class="pl-smi">A</span><span class="pl-kos">,</span> <span class="pl-smi">B</span> <span class="pl-k">extends</span> <span class="pl-smi">A</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">arg</span>: <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">B</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-en">h</span><span class="pl-kos">&lt;</span><span class="pl-kos">{</span><span class="pl-c1">x</span>: <span class="pl-smi">string</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-kos">{</span>
        <span class="pl-c1">x</span>: <span class="pl-s">"hello"</span><span class="pl-kos">,</span>
        <span class="pl-c1">y</span>: <span class="pl-c1">10</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">I have a function that produces a higher-order react component by taking a function that knows how to take a set of "external props", run a function taking the external props returning "computed props".  The union of the external props and the computed props is a set of "internal props", which the internal React component can rely on.</p>
<p dir="auto">I want the caller to specify just one of these property sets, and have everything else be inferred by the function argument passed in.  The code above is a simplified example of this.</p>
<p dir="auto">Note that only one type parameter is specified -- I would hope the second could be inferred by the function argument (like C++).</p>
<p dir="auto">However, instead I get a "Supplied parameters do not match any signature of call target." error.</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.0</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface Class&lt;T&gt; {
    new(): T;
}
declare function create1&lt;T&gt;(ctor: Class&lt;T&gt;): T;
declare function create2&lt;T, C extends Class&lt;T&gt;&gt;(ctor: C): T;

class A {}
let a1 = create1(A); // a: A --&gt; OK
let a2 = create2(A); // a: {} --&gt; Should be A"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">Class</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-k">declare</span> <span class="pl-k">function</span> <span class="pl-s1">create1</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">ctor</span>: <span class="pl-smi">Class</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">;</span>
<span class="pl-k">declare</span> <span class="pl-k">function</span> <span class="pl-s1">create2</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">C</span> <span class="pl-k">extends</span> <span class="pl-smi">Class</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">ctor</span>: <span class="pl-smi">C</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">;</span>

<span class="pl-k">class</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-k">let</span> <span class="pl-s1">a1</span> <span class="pl-c1">=</span> <span class="pl-en">create1</span><span class="pl-kos">(</span><span class="pl-smi">A</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// a: A --&gt; OK</span>
<span class="pl-k">let</span> <span class="pl-s1">a2</span> <span class="pl-c1">=</span> <span class="pl-en">create2</span><span class="pl-kos">(</span><span class="pl-smi">A</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// a: {} --&gt; Should be A</span></pre></div>
<p dir="auto"><strong>Context</strong></p>
<p dir="auto">The example above is simplified to illustrate the difference between <code class="notranslate">create1</code> and <code class="notranslate">create2</code>. I need both type parameters for the use case I have in mind (React) because it returns a type which is parameterized by both <code class="notranslate">T</code> and <code class="notranslate">C</code>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare function createElement&lt;T, C extends Class&lt;T&gt;&gt;(type: C): Element&lt;T, C&gt;;
var e = createElement(A); // e: Element&lt;{}, typeof A&gt; --&gt; Should be Element&lt;A, typeof A&gt;

declare function render&lt;T&gt;(e: Element&lt;T, any&gt;): T;
var a = render(e); // a: {} --&gt; Should be A"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">function</span> <span class="pl-s1">createElement</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">C</span> <span class="pl-k">extends</span> <span class="pl-smi">Class</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">type</span>: <span class="pl-smi">C</span><span class="pl-kos">)</span>: <span class="pl-smi">Element</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">C</span><span class="pl-kos">&gt;</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">e</span> <span class="pl-c1">=</span> <span class="pl-en">createElement</span><span class="pl-kos">(</span><span class="pl-smi">A</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// e: Element&lt;{}, typeof A&gt; --&gt; Should be Element&lt;A, typeof A&gt;</span>

<span class="pl-k">declare</span> <span class="pl-k">function</span> <span class="pl-s1">render</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">e</span>: <span class="pl-smi">Element</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">any</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">;</span>
<span class="pl-k">var</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-en">render</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// a: {} --&gt; Should be A</span></pre></div>
<p dir="auto">Again, this is simplified, but the motivation is to improve the return type inference of <code class="notranslate">ReactDOM.render</code>.</p>