title: Typescript conditional types based upon a function type
body: <p>Is it possible in Typescript to write a conditional type based upon a function type?</p>
  <p>We can implement conditional types based up on an object interface but was wondering if we can do the same with respect to a function type.</p>
  <p>Something like below:</p>
  <pre><code>type func&lt;T&gt; = (val: any) =&gt; T
  type Optional&lt;T&gt; = (val: any) =&gt; T | undefined
  
  type FilterOptional&lt;T&gt; = T extends Optional&lt;any&gt; ? undefined : T
  
  type a = FilterOptional&lt;(val: any) =&gt; number&gt;
  // a is undefined but need it to be (val: any) =&gt; number
  </code></pre>