2014-10-10 23:23:12 +02:00
|
|
|
=== tests/cases/conformance/types/tuple/typeInferenceWithTupleType.ts ===
|
|
|
|
function combine<T, U>(x: T, y: U): [T, U] {
|
2015-04-13 23:01:57 +02:00
|
|
|
>combine : <T, U>(x: T, y: U) => [T, U], Symbol(combine, Decl(typeInferenceWithTupleType.ts, 0, 0))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 0, 17))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 0, 19))
|
|
|
|
>x : T, Symbol(x, Decl(typeInferenceWithTupleType.ts, 0, 23))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 0, 17))
|
|
|
|
>y : U, Symbol(y, Decl(typeInferenceWithTupleType.ts, 0, 28))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 0, 19))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 0, 17))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 0, 19))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
return [x, y];
|
|
|
|
>[x, y] : [T, U]
|
2015-04-13 23:01:57 +02:00
|
|
|
>x : T, Symbol(x, Decl(typeInferenceWithTupleType.ts, 0, 23))
|
|
|
|
>y : U, Symbol(y, Decl(typeInferenceWithTupleType.ts, 0, 28))
|
2014-10-10 23:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var combineResult = combine("string", 10);
|
2015-04-13 23:01:57 +02:00
|
|
|
>combineResult : [string, number], Symbol(combineResult, Decl(typeInferenceWithTupleType.ts, 4, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>combine("string", 10) : [string, number]
|
2015-04-13 23:01:57 +02:00
|
|
|
>combine : <T, U>(x: T, y: U) => [T, U], Symbol(combine, Decl(typeInferenceWithTupleType.ts, 0, 0))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"string" : string
|
|
|
|
>10 : number
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
var combineEle1 = combineResult[0]; // string
|
2015-04-13 23:01:57 +02:00
|
|
|
>combineEle1 : string, Symbol(combineEle1, Decl(typeInferenceWithTupleType.ts, 5, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>combineResult[0] : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>combineResult : [string, number], Symbol(combineResult, Decl(typeInferenceWithTupleType.ts, 4, 3))
|
2015-04-13 22:54:22 +02:00
|
|
|
>0 : number, Symbol(0)
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
var combineEle2 = combineResult[1]; // number
|
2015-04-13 23:01:57 +02:00
|
|
|
>combineEle2 : number, Symbol(combineEle2, Decl(typeInferenceWithTupleType.ts, 6, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>combineResult[1] : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>combineResult : [string, number], Symbol(combineResult, Decl(typeInferenceWithTupleType.ts, 4, 3))
|
2015-04-13 22:54:22 +02:00
|
|
|
>1 : number, Symbol(1)
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
function zip<T, U>(array1: T[], array2: U[]): [[T, U]] {
|
2015-04-13 23:01:57 +02:00
|
|
|
>zip : <T, U>(array1: T[], array2: U[]) => [[T, U]], Symbol(zip, Decl(typeInferenceWithTupleType.ts, 6, 35))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 8, 13))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 8, 15))
|
|
|
|
>array1 : T[], Symbol(array1, Decl(typeInferenceWithTupleType.ts, 8, 19))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 8, 13))
|
|
|
|
>array2 : U[], Symbol(array2, Decl(typeInferenceWithTupleType.ts, 8, 31))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 8, 15))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 8, 13))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 8, 15))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
if (array1.length != array2.length) {
|
|
|
|
>array1.length != array2.length : boolean
|
2015-04-13 23:01:57 +02:00
|
|
|
>array1.length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
|
|
>array1 : T[], Symbol(array1, Decl(typeInferenceWithTupleType.ts, 8, 19))
|
|
|
|
>length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
|
|
>array2.length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
|
|
>array2 : U[], Symbol(array2, Decl(typeInferenceWithTupleType.ts, 8, 31))
|
|
|
|
>length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
return [[undefined, undefined]];
|
|
|
|
>[[undefined, undefined]] : [[undefined, undefined]]
|
|
|
|
>[undefined, undefined] : [undefined, undefined]
|
2015-04-13 22:54:22 +02:00
|
|
|
>undefined : undefined, Symbol(undefined)
|
|
|
|
>undefined : undefined, Symbol(undefined)
|
2014-10-10 23:23:12 +02:00
|
|
|
}
|
|
|
|
var length = array1.length;
|
2015-04-13 23:01:57 +02:00
|
|
|
>length : number, Symbol(length, Decl(typeInferenceWithTupleType.ts, 12, 7))
|
|
|
|
>array1.length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
|
|
|
>array1 : T[], Symbol(array1, Decl(typeInferenceWithTupleType.ts, 8, 19))
|
|
|
|
>length : number, Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
var zipResult: [[T, U]];
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult : [[T, U]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 13, 7))
|
|
|
|
>T : T, Symbol(T, Decl(typeInferenceWithTupleType.ts, 8, 13))
|
|
|
|
>U : U, Symbol(U, Decl(typeInferenceWithTupleType.ts, 8, 15))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < length; ++i) {
|
2015-04-13 23:01:57 +02:00
|
|
|
>i : number, Symbol(i, Decl(typeInferenceWithTupleType.ts, 14, 12))
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
2014-10-10 23:23:12 +02:00
|
|
|
>i < length : boolean
|
2015-04-13 23:01:57 +02:00
|
|
|
>i : number, Symbol(i, Decl(typeInferenceWithTupleType.ts, 14, 12))
|
|
|
|
>length : number, Symbol(length, Decl(typeInferenceWithTupleType.ts, 12, 7))
|
2014-10-10 23:23:12 +02:00
|
|
|
>++i : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>i : number, Symbol(i, Decl(typeInferenceWithTupleType.ts, 14, 12))
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
zipResult.push([array1[i], array2[i]]);
|
|
|
|
>zipResult.push([array1[i], array2[i]]) : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult.push : (...items: [T, U][]) => number, Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
|
|
|
>zipResult : [[T, U]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 13, 7))
|
|
|
|
>push : (...items: [T, U][]) => number, Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
|
2014-10-10 23:23:12 +02:00
|
|
|
>[array1[i], array2[i]] : [T, U]
|
|
|
|
>array1[i] : T
|
2015-04-13 23:01:57 +02:00
|
|
|
>array1 : T[], Symbol(array1, Decl(typeInferenceWithTupleType.ts, 8, 19))
|
|
|
|
>i : number, Symbol(i, Decl(typeInferenceWithTupleType.ts, 14, 12))
|
2014-10-10 23:23:12 +02:00
|
|
|
>array2[i] : U
|
2015-04-13 23:01:57 +02:00
|
|
|
>array2 : U[], Symbol(array2, Decl(typeInferenceWithTupleType.ts, 8, 31))
|
|
|
|
>i : number, Symbol(i, Decl(typeInferenceWithTupleType.ts, 14, 12))
|
2014-10-10 23:23:12 +02:00
|
|
|
}
|
|
|
|
return zipResult;
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult : [[T, U]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 13, 7))
|
2014-10-10 23:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var zipResult = zip(["foo", "bar"], [5, 6]);
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult : [[string, number]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 20, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>zip(["foo", "bar"], [5, 6]) : [[string, number]]
|
2015-04-13 23:01:57 +02:00
|
|
|
>zip : <T, U>(array1: T[], array2: U[]) => [[T, U]], Symbol(zip, Decl(typeInferenceWithTupleType.ts, 6, 35))
|
2014-10-10 23:23:12 +02:00
|
|
|
>["foo", "bar"] : string[]
|
2015-04-13 21:36:11 +02:00
|
|
|
>"foo" : string
|
|
|
|
>"bar" : string
|
2014-10-10 23:23:12 +02:00
|
|
|
>[5, 6] : number[]
|
2015-04-13 21:36:11 +02:00
|
|
|
>5 : number
|
|
|
|
>6 : number
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
var zipResultEle = zipResult[0]; // [string, number]
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResultEle : [string, number], Symbol(zipResultEle, Decl(typeInferenceWithTupleType.ts, 21, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>zipResult[0] : [string, number]
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult : [[string, number]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 20, 3))
|
2015-04-13 22:54:22 +02:00
|
|
|
>0 : number, Symbol(0)
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
var zipResultEleEle = zipResult[0][0]; // string
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResultEleEle : string, Symbol(zipResultEleEle, Decl(typeInferenceWithTupleType.ts, 22, 3))
|
2014-10-10 23:23:12 +02:00
|
|
|
>zipResult[0][0] : string
|
|
|
|
>zipResult[0] : [string, number]
|
2015-04-13 23:01:57 +02:00
|
|
|
>zipResult : [[string, number]], Symbol(zipResult, Decl(typeInferenceWithTupleType.ts, 20, 3))
|
2015-04-13 22:54:22 +02:00
|
|
|
>0 : number, Symbol(0)
|
|
|
|
>0 : number, Symbol(0)
|
2014-10-10 23:23:12 +02:00
|
|
|
|
|
|
|
|