title: Why are first class functions not type checked in typescript?
body: <p>In the example below, the <code>Promise::then</code> visitor function <code>f</code> has an expectation of receiving an <code>Example</code>.  If I explicitly pass in a malformed object with missing properties, I get a type error.</p>
  
  <p>But if I simply pass the function <code>f</code> to <code>.then(f)</code> I get no type error, even though typescript knows the type of the <code>T</code> in <code>Promise&lt;T&gt;</code> is not an <code>Example</code>.</p>
  
  <pre><code>interface Example {
      id: number
      age: number
  }
  
  interface Promise &lt;T&gt; {
      then &lt;U&gt; ( f: ( a: T) =&gt; U ) : Promise&lt;U&gt; 
  }
  
  function f(s:Example){
      return s.age
  }
  
  var p : Promise&lt;{ id: number }&gt;
  
  p.then(f) // no type error (bad)
  
  p.then(function(a){
      f(a) // type error (good)
  })
  </code></pre>
  
  <p>I'm wondering why this happens but also, techniques to mitigate permissive type checking in Typescript.</p>
  
  <p>If bivariance explains this phenomenon, then why is there a type error when <code>f</code> is explicitly applied?  Why are their different rules for 1st class functions vs explicit application?</p>