Microsoft/TypeScript — pull request #908 by ahejlsberg (2014-10-16 23:32:37+00:00)
Title: Union types in contextual signature instantiations

This aligns Contextual Signature Instantiation with the latest spec:

https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.8.5

An example:
```typescript
declare function foo(cb: (x: number, y: string) => T): T;
declare function bar(x: number, y: string): boolean;
declare function g(x: T, y: T): T;

var a = foo(bar); // a: boolean
var b = foo(g); // b: number | string
```
The old compiler would infer '{}' for 'b' because number and string has no best common type. The new compiler currently infers 'any' because inference fails and produces the Undefined type which then gets widened to 'any'. With this change the new compiler infers 'number | string' which aligns with the new spec (and, IMO, is the most meaningful thing to do).