widenToAny2.ts(2,5): error TS2322: Type 'undefined' is not assignable to type 'T'.
  'T' could be instantiated with an arbitrary type which could be unrelated to 'undefined'.
widenToAny2.ts(4,5): error TS2322: Type 'string | undefined' is not assignable to type 'number'.
  Type 'undefined' is not assignable to type 'number'.


==== widenToAny2.ts (2 errors) ====
    function foo3<T>(x: T[]): T {
        return undefined;
        ~~~~~~
!!! error TS2322: Type 'undefined' is not assignable to type 'T'.
!!! error TS2322:   'T' could be instantiated with an arbitrary type which could be unrelated to 'undefined'.
    }
    var z3:number = foo3([undefined, "def"]);  // Type is any, but should be string
        ~~
!!! error TS2322: Type 'string | undefined' is not assignable to type 'number'.
!!! error TS2322:   Type 'undefined' is not assignable to type 'number'.
    