2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithArrayLiteralArgs.ts ===
|
|
|
|
function foo<T>(t: T) {
|
|
|
|
>foo : <T>(t: T) => T
|
|
|
|
>T : T
|
|
|
|
>t : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
return t;
|
|
|
|
>t : T
|
|
|
|
}
|
|
|
|
|
|
|
|
var r = foo([1, 2]); // number[]
|
|
|
|
>r : number[]
|
|
|
|
>foo([1, 2]) : number[]
|
|
|
|
>foo : <T>(t: T) => T
|
|
|
|
>[1, 2] : number[]
|
|
|
|
|
|
|
|
var r = foo<number[]>([1, 2]); // number[]
|
|
|
|
>r : number[]
|
|
|
|
>foo<number[]>([1, 2]) : number[]
|
|
|
|
>foo : <T>(t: T) => T
|
|
|
|
>[1, 2] : number[]
|
|
|
|
|
|
|
|
var ra = foo<any[]>([1, 2]); // any[]
|
|
|
|
>ra : any[]
|
|
|
|
>foo<any[]>([1, 2]) : any[]
|
|
|
|
>foo : <T>(t: T) => T
|
2014-10-13 15:56:58 +02:00
|
|
|
>[1, 2] : number[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var r2 = foo([]); // any[]
|
|
|
|
>r2 : any[]
|
|
|
|
>foo([]) : any[]
|
|
|
|
>foo : <T>(t: T) => T
|
2014-10-13 15:56:58 +02:00
|
|
|
>[] : undefined[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var r3 = foo<number[]>([]); // number[]
|
|
|
|
>r3 : number[]
|
|
|
|
>foo<number[]>([]) : number[]
|
|
|
|
>foo : <T>(t: T) => T
|
2014-10-13 15:56:58 +02:00
|
|
|
>[] : undefined[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var r4 = foo([1, '']); // {}[]
|
2014-10-18 01:53:18 +02:00
|
|
|
>r4 : (string | number)[]
|
|
|
|
>foo([1, '']) : (string | number)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
>foo : <T>(t: T) => T
|
2014-10-18 01:53:18 +02:00
|
|
|
>[1, ''] : (string | number)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var r5 = foo<any[]>([1, '']); // any[]
|
|
|
|
>r5 : any[]
|
|
|
|
>foo<any[]>([1, '']) : any[]
|
|
|
|
>foo : <T>(t: T) => T
|
2014-10-18 01:53:18 +02:00
|
|
|
>[1, ''] : (string | number)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var r6 = foo<Object[]>([1, '']); // Object[]
|
|
|
|
>r6 : Object[]
|
|
|
|
>foo<Object[]>([1, '']) : Object[]
|
|
|
|
>foo : <T>(t: T) => T
|
|
|
|
>Object : Object
|
2014-10-18 01:53:18 +02:00
|
|
|
>[1, ''] : (string | number)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|