TypeScript/tests/baselines/reference/genericCallWithFunctionTypedArguments3.types

57 lines
2.8 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments3.ts ===
// No inference is made from function typed arguments which have multiple call signatures
var a: {
2015-04-13 23:01:57 +02:00
>a : { (x: boolean): boolean; (x: string): any; }, Symbol(a, Decl(genericCallWithFunctionTypedArguments3.ts, 2, 3))
2014-08-15 23:33:16 +02:00
(x: boolean): boolean;
2015-04-13 23:01:57 +02:00
>x : boolean, Symbol(x, Decl(genericCallWithFunctionTypedArguments3.ts, 3, 5))
2014-08-15 23:33:16 +02:00
(x: string): any;
2015-04-13 23:01:57 +02:00
>x : string, Symbol(x, Decl(genericCallWithFunctionTypedArguments3.ts, 4, 5))
2014-08-15 23:33:16 +02:00
}
function foo4<T, U>(cb: (x: T) => U) {
2015-04-13 23:01:57 +02:00
>foo4 : <T, U>(cb: (x: T) => U) => U, Symbol(foo4, Decl(genericCallWithFunctionTypedArguments3.ts, 5, 1))
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 14))
>U : U, Symbol(U, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 16))
>cb : (x: T) => U, Symbol(cb, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 20))
>x : T, Symbol(x, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 25))
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 14))
>U : U, Symbol(U, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 16))
2014-08-15 23:33:16 +02:00
var u: U;
2015-04-13 23:01:57 +02:00
>u : U, Symbol(u, Decl(genericCallWithFunctionTypedArguments3.ts, 8, 7))
>U : U, Symbol(U, Decl(genericCallWithFunctionTypedArguments3.ts, 7, 16))
2014-08-15 23:33:16 +02:00
return u;
2015-04-13 23:01:57 +02:00
>u : U, Symbol(u, Decl(genericCallWithFunctionTypedArguments3.ts, 8, 7))
2014-08-15 23:33:16 +02:00
}
var r = foo4(a); // T is {} (candidates boolean and string), U is any (candidates any and boolean)
2015-04-13 23:01:57 +02:00
>r : any, Symbol(r, Decl(genericCallWithFunctionTypedArguments3.ts, 12, 3))
2014-08-15 23:33:16 +02:00
>foo4(a) : any
2015-04-13 23:01:57 +02:00
>foo4 : <T, U>(cb: (x: T) => U) => U, Symbol(foo4, Decl(genericCallWithFunctionTypedArguments3.ts, 5, 1))
>a : { (x: boolean): boolean; (x: string): any; }, Symbol(a, Decl(genericCallWithFunctionTypedArguments3.ts, 2, 3))
2014-08-15 23:33:16 +02:00
var b: {
2015-04-13 23:01:57 +02:00
>b : { <T>(x: boolean): T; <T>(x: T): any; }, Symbol(b, Decl(genericCallWithFunctionTypedArguments3.ts, 14, 3))
2014-08-15 23:33:16 +02:00
<T>(x: boolean): T;
2015-04-13 23:01:57 +02:00
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 15, 5))
>x : boolean, Symbol(x, Decl(genericCallWithFunctionTypedArguments3.ts, 15, 8))
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 15, 5))
2014-08-15 23:33:16 +02:00
<T>(x: T): any;
2015-04-13 23:01:57 +02:00
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 16, 5))
>x : T, Symbol(x, Decl(genericCallWithFunctionTypedArguments3.ts, 16, 8))
>T : T, Symbol(T, Decl(genericCallWithFunctionTypedArguments3.ts, 16, 5))
2014-08-15 23:33:16 +02:00
}
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
2015-04-13 23:01:57 +02:00
>r2 : any, Symbol(r2, Decl(genericCallWithFunctionTypedArguments3.ts, 19, 3))
2014-08-15 23:33:16 +02:00
>foo4(b) : any
2015-04-13 23:01:57 +02:00
>foo4 : <T, U>(cb: (x: T) => U) => U, Symbol(foo4, Decl(genericCallWithFunctionTypedArguments3.ts, 5, 1))
>b : { <T>(x: boolean): T; <T>(x: T): any; }, Symbol(b, Decl(genericCallWithFunctionTypedArguments3.ts, 14, 3))
2014-08-15 23:33:16 +02:00