TypeScript/tests/baselines/reference/genericCallWithFunctionTypedArguments4.types
2015-04-15 16:44:20 -07:00

67 lines
1.3 KiB
Plaintext

=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments4.ts ===
// No inference is made from function typed arguments which have multiple call signatures
class C { foo: string }
>C : C
>foo : string
class D { bar: string }
>D : D
>bar : string
var a: {
>a : { new (x: boolean): C; new (x: string): D; }
new(x: boolean): C;
>x : boolean
>C : C
new(x: string): D;
>x : string
>D : D
}
function foo4<T, U>(cb: new(x: T) => U) {
>foo4 : <T, U>(cb: new (x: T) => U) => U
>T : T
>U : U
>cb : new (x: T) => U
>x : T
>T : T
>U : U
var u: U;
>u : U
>U : U
return u;
>u : U
}
var r = foo4(a); // T is {} (candidates boolean and string), U is {} (candidates C and D)
>r : D
>foo4(a) : D
>foo4 : <T, U>(cb: new (x: T) => U) => U
>a : { new (x: boolean): C; new (x: string): D; }
var b: {
>b : { new <T>(x: boolean): T; new <T>(x: T): any; }
new<T>(x: boolean): T;
>T : T
>x : boolean
>T : T
new<T>(x: T): any;
>T : T
>x : T
>T : T
}
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
>r2 : any
>foo4(b) : any
>foo4 : <T, U>(cb: new (x: T) => U) => U
>b : { new <T>(x: boolean): T; new <T>(x: T): any; }