2014-08-11 21:21:26 +02:00
|
|
|
var v1: []; // Error
|
|
|
|
var v2: [number];
|
|
|
|
var v3: [number, string];
|
|
|
|
var v4: [number, [string, string]];
|
|
|
|
|
|
|
|
var t: [number, string];
|
|
|
|
var t0 = t[0]; // number
|
|
|
|
var t0: number;
|
|
|
|
var t1 = t[1]; // string
|
|
|
|
var t1: string;
|
2014-10-10 23:41:14 +02:00
|
|
|
var t2 = t[2]; // number|string
|
|
|
|
var t2: number|string;
|
2014-08-11 21:21:26 +02:00
|
|
|
|
|
|
|
t = []; // Error
|
|
|
|
t = [1]; // Error
|
|
|
|
t = [1, "hello"]; // Ok
|
|
|
|
t = ["hello", 1]; // Error
|
2017-11-03 17:56:39 +01:00
|
|
|
t = [1, "hello", 2]; // Error
|
2014-08-11 21:21:26 +02:00
|
|
|
|
|
|
|
var tf: [string, (x: string) => number] = ["hello", x => x.length];
|
|
|
|
|
|
|
|
declare function ff<T, U>(a: T, b: [T, (x: T) => U]): U;
|
|
|
|
var ff1 = ff("hello", ["foo", x => x.length]);
|
|
|
|
var ff1: number;
|
|
|
|
|
|
|
|
function tuple2<T0, T1>(item0: T0, item1: T1): [T0, T1]{
|
|
|
|
return [item0, item1];
|
|
|
|
}
|
|
|
|
|
|
|
|
var tt = tuple2(1, "string");
|
|
|
|
var tt0 = tt[0];
|
|
|
|
var tt0: number;
|
|
|
|
var tt1 = tt[1];
|
|
|
|
var tt1: string;
|
2014-10-10 23:41:14 +02:00
|
|
|
var tt2 = tt[2];
|
|
|
|
var tt2: number | string;
|
2014-08-11 21:21:26 +02:00
|
|
|
|
|
|
|
tt = tuple2(1, undefined);
|
|
|
|
tt = [1, undefined];
|
|
|
|
tt = [undefined, undefined];
|
|
|
|
tt = []; // Error
|
|
|
|
|
|
|
|
var a: number[];
|
|
|
|
var a1: [number, string];
|
|
|
|
var a2: [number, number];
|
|
|
|
var a3: [number, {}];
|
|
|
|
a = a1; // Error
|
|
|
|
a = a2;
|
|
|
|
a = a3; // Error
|
|
|
|
a1 = a2; // Error
|
|
|
|
a1 = a3; // Error
|
|
|
|
a3 = a1;
|
|
|
|
a3 = a2;
|