2014-10-09 00:37:01 +02:00
|
|
|
=== tests/cases/conformance/types/tuple/indexerWithTuple.ts ===
|
|
|
|
var strNumTuple: [string, number] = ["foo", 10];
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
>["foo", 10] : [string, number]
|
|
|
|
|
|
|
|
var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]];
|
|
|
|
>numTupleTuple : [number, [string, number]]
|
|
|
|
>[10, ["bar", 20]] : [number, [string, number]]
|
|
|
|
>["bar", 20] : [string, number]
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var unionTuple1: [number, string| number] = [10, "foo"];
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
>[10, "foo"] : [number, string]
|
|
|
|
|
|
|
|
var unionTuple2: [boolean, string| number] = [true, "foo"];
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
>[true, "foo"] : [boolean, string]
|
|
|
|
|
2014-10-09 00:37:01 +02:00
|
|
|
// no error
|
|
|
|
var idx0 = 0;
|
|
|
|
>idx0 : number
|
|
|
|
|
|
|
|
var idx1 = 1;
|
|
|
|
>idx1 : number
|
|
|
|
|
|
|
|
var ele10 = strNumTuple[0]; // string
|
|
|
|
>ele10 : string
|
|
|
|
>strNumTuple[0] : string
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
|
|
|
|
var ele11 = strNumTuple[1]; // number
|
|
|
|
>ele11 : number
|
|
|
|
>strNumTuple[1] : number
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var ele12 = strNumTuple[2]; // string | number
|
2014-10-09 00:37:01 +02:00
|
|
|
>ele12 : string | number
|
|
|
|
>strNumTuple[2] : string | number
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var ele13 = strNumTuple[idx0]; // string | number
|
2014-10-09 00:37:01 +02:00
|
|
|
>ele13 : string | number
|
|
|
|
>strNumTuple[idx0] : string | number
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
>idx0 : number
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var ele14 = strNumTuple[idx1]; // string | number
|
2014-10-09 00:37:01 +02:00
|
|
|
>ele14 : string | number
|
|
|
|
>strNumTuple[idx1] : string | number
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
>idx1 : number
|
|
|
|
|
|
|
|
var ele15 = strNumTuple["0"]; // string
|
|
|
|
>ele15 : string
|
|
|
|
>strNumTuple["0"] : string
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
|
|
|
|
var ele16 = strNumTuple["1"]; // number
|
|
|
|
>ele16 : number
|
|
|
|
>strNumTuple["1"] : number
|
|
|
|
>strNumTuple : [string, number]
|
|
|
|
|
|
|
|
var strNumTuple1 = numTupleTuple[1]; //[string, number];
|
|
|
|
>strNumTuple1 : [string, number]
|
|
|
|
>numTupleTuple[1] : [string, number]
|
|
|
|
>numTupleTuple : [number, [string, number]]
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var ele17 = numTupleTuple[2]; // number | [string, number]
|
2014-10-09 00:37:01 +02:00
|
|
|
>ele17 : number | [string, number]
|
|
|
|
>numTupleTuple[2] : number | [string, number]
|
|
|
|
>numTupleTuple : [number, [string, number]]
|
|
|
|
|
2014-11-03 18:06:40 +01:00
|
|
|
var eleUnion10 = unionTuple1[0]; // number
|
|
|
|
>eleUnion10 : number
|
|
|
|
>unionTuple1[0] : number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
|
|
|
|
var eleUnion11 = unionTuple1[1]; // string | number
|
|
|
|
>eleUnion11 : string | number
|
|
|
|
>unionTuple1[1] : string | number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
|
|
|
|
var eleUnion12 = unionTuple1[2]; // string | number
|
|
|
|
>eleUnion12 : string | number
|
|
|
|
>unionTuple1[2] : string | number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
|
|
|
|
var eleUnion13 = unionTuple1[idx0]; // string | number
|
|
|
|
>eleUnion13 : string | number
|
|
|
|
>unionTuple1[idx0] : string | number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
>idx0 : number
|
|
|
|
|
|
|
|
var eleUnion14 = unionTuple1[idx1]; // string | number
|
|
|
|
>eleUnion14 : string | number
|
|
|
|
>unionTuple1[idx1] : string | number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
>idx1 : number
|
|
|
|
|
|
|
|
var eleUnion15 = unionTuple1["0"]; // number
|
|
|
|
>eleUnion15 : number
|
|
|
|
>unionTuple1["0"] : number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
|
|
|
|
var eleUnion16 = unionTuple1["1"]; // string | number
|
|
|
|
>eleUnion16 : string | number
|
|
|
|
>unionTuple1["1"] : string | number
|
|
|
|
>unionTuple1 : [number, string | number]
|
|
|
|
|
|
|
|
var eleUnion20 = unionTuple2[0]; // boolean
|
|
|
|
>eleUnion20 : boolean
|
|
|
|
>unionTuple2[0] : boolean
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
|
|
|
|
var eleUnion21 = unionTuple2[1]; // string | number
|
|
|
|
>eleUnion21 : string | number
|
|
|
|
>unionTuple2[1] : string | number
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
|
|
|
|
var eleUnion22 = unionTuple2[2]; // string | number | boolean
|
|
|
|
>eleUnion22 : string | number | boolean
|
|
|
|
>unionTuple2[2] : string | number | boolean
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
|
|
|
|
var eleUnion23 = unionTuple2[idx0]; // string | number | boolean
|
|
|
|
>eleUnion23 : string | number | boolean
|
|
|
|
>unionTuple2[idx0] : string | number | boolean
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
>idx0 : number
|
|
|
|
|
|
|
|
var eleUnion24 = unionTuple2[idx1]; // string | number | boolean
|
|
|
|
>eleUnion24 : string | number | boolean
|
|
|
|
>unionTuple2[idx1] : string | number | boolean
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
>idx1 : number
|
|
|
|
|
|
|
|
var eleUnion25 = unionTuple2["0"]; // boolean
|
|
|
|
>eleUnion25 : boolean
|
|
|
|
>unionTuple2["0"] : boolean
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
|
|
|
|
var eleUnion26 = unionTuple2["1"]; // string | number
|
|
|
|
>eleUnion26 : string | number
|
|
|
|
>unionTuple2["1"] : string | number
|
|
|
|
>unionTuple2 : [boolean, string | number]
|
|
|
|
|