functionOverloads43.ts(8,5): error TS2322: Type 'undefined' is not assignable to type 'string | number'.


==== functionOverloads43.ts (1 errors) ====
    function foo(bar: { a:number }[]): number;
    function foo(bar: { a:string }[]): string;
    function foo([x]: { a:number | string }[]): string | number {
        if (x) {
            return x.a;
        }
        
        return undefined;
        ~~~~~~
!!! error TS2322: Type 'undefined' is not assignable to type 'string | number'.
    }
    
    var x = foo([{a: "str"}]);
    var y = foo([{a: 100}]);