<p dir="auto"><strong>TypeScript Version:</strong> 1.9.0-dev.20160523-1.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="// A self-contained demonstration of the problem follows...

class Foo {

  identity&lt;T&gt;(x: T): T {
    return x
  }

  compose&lt;A, B, C&gt;(f: (b: B) =&gt; C, g: (a: A) =&gt; B) : (a:A) =&gt; C {
    return (a: A) =&gt; f(g(a))
  }

  constructor()  {
    let value = this.compose((a : number) =&gt; a, this.identity)
  }
}
"><pre class="notranslate"><span class="pl-c">// A self-contained demonstration of the problem follows...</span>

<span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>

  <span class="pl-en">identity</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">x</span>: <span class="pl-smi">T</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-s1">x</span>
  <span class="pl-kos">}</span>

  <span class="pl-en">compose</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-kos">,</span> <span class="pl-smi">C</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">f</span>: <span class="pl-kos">(</span><span class="pl-s1">b</span>: <span class="pl-smi">B</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">C</span><span class="pl-kos">,</span> <span class="pl-s1">g</span>: <span class="pl-kos">(</span><span class="pl-s1">a</span>: <span class="pl-smi">A</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-s1">a</span>:<span class="pl-smi">A</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">C</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-kos">(</span><span class="pl-s1">a</span>: <span class="pl-smi">A</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">f</span><span class="pl-kos">(</span><span class="pl-en">g</span><span class="pl-kos">(</span><span class="pl-s1">a</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span>

  <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-kos">)</span>  <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-en">compose</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">a</span> : <span class="pl-smi">number</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">a</span><span class="pl-kos">,</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">identity</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">value should have type (a: number) =&gt; number<br>
OR<br>
it should issue an error as the tsconfig.json has "noImplicitAny" defined to true.</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">value has type (a: {}) =&gt; number<br>
AND<br>
no error from the compiler.</p>
<p dir="auto">I'm using TypeScript 1.6.3 in Visual Studio 2015.  The es6-promise declaration I'm using contains:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="declare class Promise&lt;R&gt; implements Thenable&lt;R&gt; {
    constructor(callback: (resolve : (value?: R | Thenable&lt;R&gt;) =&gt; void, reject: (error?: any) =&gt; void) =&gt; void);
    then&lt;U&gt;(onFulfilled?: (value: R) =&gt; U | Thenable&lt;U&gt;, onRejected?: (error: any) =&gt; U | Thenable&lt;U&gt;): Promise&lt;U&gt;;
}"><pre class="notranslate"><code class="notranslate">declare class Promise&lt;R&gt; implements Thenable&lt;R&gt; {
    constructor(callback: (resolve : (value?: R | Thenable&lt;R&gt;) =&gt; void, reject: (error?: any) =&gt; void) =&gt; void);
    then&lt;U&gt;(onFulfilled?: (value: R) =&gt; U | Thenable&lt;U&gt;, onRejected?: (error: any) =&gt; U | Thenable&lt;U&gt;): Promise&lt;U&gt;;
}
</code></pre></div>
<p dir="auto">The following works with an explicit typing of the Promise generic:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="new Promise &lt; { foo: number }&gt;((resolve) =&gt; {
    resolve({ foo: 1 });
}).then((value) =&gt; {
    value.foo;
});"><pre class="notranslate"><code class="notranslate">new Promise &lt; { foo: number }&gt;((resolve) =&gt; {
    resolve({ foo: 1 });
}).then((value) =&gt; {
    value.foo;
});
</code></pre></div>
<p dir="auto">However, shouldn't type inference allow the following to work?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="new Promise((resolve) =&gt; {
    resolve({ foo: 1 });
}).then((value) =&gt; {
    value.foo;
});"><pre class="notranslate"><code class="notranslate">new Promise((resolve) =&gt; {
    resolve({ foo: 1 });
}).then((value) =&gt; {
    value.foo;
});
</code></pre></div>
<p dir="auto">Instead, I am getting an error when accessing value.foo that foo does not exist on type '{}'.  Why is TypeScript defaulting to the <code class="notranslate">{}</code> type?</p>