//// [tests/cases/conformance/types/union/contextualTypeWithUnionTypeCallSignatures.ts] ////

=== contextualTypeWithUnionTypeCallSignatures.ts ===
//When used as a contextual type, a union type U has those members that are present in any of 
// its constituent types, with types that are unions of the respective members in the constituent types. 

// Let S be the set of types in U that have call signatures.
// If S is not empty and the sets of call signatures of the types in S are identical ignoring return types,
// U has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in S.

interface IWithNoCallSignatures {
    foo: string;
>foo : string
>    : ^^^^^^
}
interface IWithCallSignatures {
    (a: number): string;
>a : number
>  : ^^^^^^
}
interface IWithCallSignatures2 {
    (a: number): number;
>a : number
>  : ^^^^^^
}
interface IWithCallSignatures3 {
    (b: string): number;
>b : string
>  : ^^^^^^
}
interface IWithCallSignatures4 {
    (a: number): string;
>a : number
>  : ^^^^^^

    (a: string, b: number): number;
>a : string
>  : ^^^^^^
>b : number
>  : ^^^^^^
}

// With no call signature | callSignatures
var x: IWithNoCallSignatures | IWithCallSignatures = a => a.toString();
>x : IWithNoCallSignatures | IWithCallSignatures
>  : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a => a.toString() : (a: number) => string
>                  : ^ ^^^^^^^^^^^^^^^^^^^
>a : number
>  : ^^^^^^
>a.toString() : string
>             : ^^^^^^
>a.toString : (radix?: number) => string
>           : ^     ^^^      ^^^^^      
>a : number
>  : ^^^^^^
>toString : (radix?: number) => string
>         : ^     ^^^      ^^^^^      

// With call signatures with different return type
var x2: IWithCallSignatures | IWithCallSignatures2 = a => a.toString(); // Like iWithCallSignatures
>x2 : IWithCallSignatures | IWithCallSignatures2
>   : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a => a.toString() : (a: number) => string
>                  : ^ ^^^^^^^^^^^^^^^^^^^
>a : number
>  : ^^^^^^
>a.toString() : string
>             : ^^^^^^
>a.toString : (radix?: number) => string
>           : ^     ^^^      ^^^^^      
>a : number
>  : ^^^^^^
>toString : (radix?: number) => string
>         : ^     ^^^      ^^^^^      

var x2: IWithCallSignatures | IWithCallSignatures2 = a => a; // Like iWithCallSignatures2
>x2 : IWithCallSignatures | IWithCallSignatures2
>   : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a => a : (a: number) => number
>       : ^ ^^^^^^^^^^^^^^^^^^^
>a : number
>  : ^^^^^^
>a : number
>  : ^^^^^^

// With call signatures of mismatching parameter type
var x3: IWithCallSignatures | IWithCallSignatures3 = a => /*here a should be any*/ a.toString();
>x3 : IWithCallSignatures | IWithCallSignatures3
>   : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a => /*here a should be any*/ a.toString() : (a: any) => any
>                                           : ^ ^^^^^^^^^^^^^
>a : any
>  : ^^^
>a.toString() : any
>             : ^^^
>a.toString : any
>           : ^^^
>a : any
>  : ^^^
>toString : any
>         : ^^^

// With call signature count mismatch
var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any*/ a.toString();
>x4 : IWithCallSignatures | IWithCallSignatures4
>   : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>a => /*here a should be any*/ a.toString() : (a: any) => any
>                                           : ^ ^^^^^^^^^^^^^
>a : any
>  : ^^^
>a.toString() : any
>             : ^^^
>a.toString : any
>           : ^^^
>a : any
>  : ^^^
>toString : any
>         : ^^^

