TypeScript/tests/baselines/reference/genericCallWithGenericSignatureArguments3.types
Wesley Wigham 5353475fce Always collect type and symbol baselines (#18621)
* Always generate type & symbol baselines

* Accept changed shadowed baselines

* Accept brand new type and symbol baselines

* Allow `getTypeAtLocation` to return undefined in the type writer

* Accept baselines which had missing type information

* Bind container for dynamically names enum members so they may be printed

* Accept type/symbol baselines for enums with computed members

* First pass at reducing typeWriter memory overhead

* Use generators to allow for type and symbol baselines with no cache

* Accept new baselines for tests whose output was fixed by better newline splitting

* Hard cap on number of declarations printed, cache declaration print text

* handle differing newlines better still to handle RWC newlines

* Lower abridging count, accept abridged baselines

* Limit max RWC error output size, limit RWC type and symbol baseline input size

* Move skip logic into type and symbol baseliner to streamline error handling

* Accept removal of empty baselines

* Canonicalize path earlier to handle odd paths in input files

* Do canonicalization earlier still, also ensure parallel perf profiles for different targets do not trample one another

* No need to pathify again
2017-09-22 15:52:04 -07:00

233 lines
6.3 KiB
Plaintext

=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments3.ts ===
// When a function expression is inferentially typed (section 4.9.3) and a type assigned to a parameter in that expression references type parameters for which inferences are being made,
// the corresponding inferred type arguments to become fixed and no further candidate inferences are made for them.
function foo<T>(x: T, a: (x: T) => T, b: (x: T) => T) {
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>T : T
>x : T
>T : T
>a : (x: T) => T
>x : T
>T : T
>T : T
>b : (x: T) => T
>x : T
>T : T
>T : T
var r: (x: T) => T;
>r : (x: T) => T
>x : T
>T : T
>T : T
return r;
>r : (x: T) => T
}
var r1 = foo('', (x: string) => '', (x: Object) => null); // any => any
>r1 : (x: any) => any
>foo('', (x: string) => '', (x: Object) => null) : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>'' : ""
>(x: string) => '' : (x: string) => string
>x : string
>'' : ""
>(x: Object) => null : (x: Object) => any
>x : Object
>Object : Object
>null : null
var r1ii = foo('', (x) => '', (x) => null); // string => string
>r1ii : (x: string) => string
>foo('', (x) => '', (x) => null) : (x: string) => string
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>'' : ""
>(x) => '' : (x: string) => string
>x : string
>'' : ""
>(x) => null : (x: string) => any
>x : string
>null : null
var r2 = foo('', (x: string) => '', (x: Object) => ''); // string => string
>r2 : (x: Object) => Object
>foo('', (x: string) => '', (x: Object) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>'' : ""
>(x: string) => '' : (x: string) => string
>x : string
>'' : ""
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>'' : ""
var r3 = foo(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r3 : (x: Object) => Object
>foo(null, (x: Object) => '', (x: string) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>null : null
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>'' : ""
>(x: string) => '' : (x: string) => string
>x : string
>'' : ""
var r4 = foo(null, (x) => '', (x) => ''); // any => any
>r4 : (x: any) => any
>foo(null, (x) => '', (x) => '') : (x: any) => any
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>null : null
>(x) => '' : (x: any) => string
>x : any
>'' : ""
>(x) => '' : (x: any) => string
>x : any
>'' : ""
var r5 = foo(new Object(), (x) => '', (x) => ''); // Object => Object
>r5 : (x: Object) => Object
>foo(new Object(), (x) => '', (x) => '') : (x: Object) => Object
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>new Object() : Object
>Object : ObjectConstructor
>(x) => '' : (x: Object) => string
>x : Object
>'' : ""
>(x) => '' : (x: Object) => string
>x : Object
>'' : ""
enum E { A }
>E : E
>A : E
enum F { A }
>F : F
>A : F
var r6 = foo(E.A, (x: number) => E.A, (x: F) => F.A); // number => number
>r6 : (x: number) => number
>foo(E.A, (x: number) => E.A, (x: F) => F.A) : (x: number) => number
>foo : <T>(x: T, a: (x: T) => T, b: (x: T) => T) => (x: T) => T
>E.A : E
>E : typeof E
>A : E
>(x: number) => E.A : (x: number) => E
>x : number
>E.A : E
>E : typeof E
>A : E
>(x: F) => F.A : (x: F) => F
>x : F
>F : F
>F.A : F
>F : typeof F
>A : F
function foo2<T, U>(x: T, a: (x: T) => U, b: (x: T) => U) {
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>T : T
>U : U
>x : T
>T : T
>a : (x: T) => U
>x : T
>T : T
>U : U
>b : (x: T) => U
>x : T
>T : T
>U : U
var r: (x: T) => U;
>r : (x: T) => U
>x : T
>T : T
>U : U
return r;
>r : (x: T) => U
}
var r8 = foo2('', (x) => '', (x) => null); // string => string
>r8 : (x: string) => any
>foo2('', (x) => '', (x) => null) : (x: string) => any
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>'' : ""
>(x) => '' : (x: string) => string
>x : string
>'' : ""
>(x) => null : (x: string) => any
>x : string
>null : null
var r9 = foo2(null, (x) => '', (x) => ''); // any => any
>r9 : (x: any) => string
>foo2(null, (x) => '', (x) => '') : (x: any) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>null : null
>(x) => '' : (x: any) => string
>x : any
>'' : ""
>(x) => '' : (x: any) => string
>x : any
>'' : ""
var r10 = foo2(null, (x: Object) => '', (x: string) => ''); // Object => Object
>r10 : (x: Object) => string
>foo2(null, (x: Object) => '', (x: string) => '') : (x: Object) => string
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>null : null
>(x: Object) => '' : (x: Object) => string
>x : Object
>Object : Object
>'' : ""
>(x: string) => '' : (x: string) => string
>x : string
>'' : ""
var x: (a: string) => boolean;
>x : (a: string) => boolean
>a : string
var r11 = foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2); // error
>r11 : any
>foo2(x, (a1: (y: string) => string) => (n: Object) => 1, (a2: (z: string) => string) => 2) : any
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => string) => (n: Object) => 1 : (a1: (y: string) => string) => (n: Object) => number
>a1 : (y: string) => string
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>1 : 1
>(a2: (z: string) => string) => 2 : (a2: (z: string) => string) => number
>a2 : (z: string) => string
>z : string
>2 : 2
var r12 = foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2); // error
>r12 : any
>foo2(x, (a1: (y: string) => boolean) => (n: Object) => 1, (a2: (z: string) => boolean) => 2) : any
>foo2 : <T, U>(x: T, a: (x: T) => U, b: (x: T) => U) => (x: T) => U
>x : (a: string) => boolean
>(a1: (y: string) => boolean) => (n: Object) => 1 : (a1: (y: string) => boolean) => (n: Object) => number
>a1 : (y: string) => boolean
>y : string
>(n: Object) => 1 : (n: Object) => number
>n : Object
>Object : Object
>1 : 1
>(a2: (z: string) => boolean) => 2 : (a2: (z: string) => boolean) => number
>a2 : (z: string) => boolean
>z : string
>2 : 2