Microsoft/TypeScript — pull request #428 by ahejlsberg (2014-08-11 19:54:13+00:00)
Title: Adding support for tuple types (e.g. [number, string])

This commit adds support for typle types. A tuple type is written as a comma separated sequence of types enclosed in square brackets:
```typescript
[T0, T1, ... , Tn]
```
A tuple type corresponds to an object type that extends `Array`, where `T` is the best common type of the tuple element types, with a sequence of numerically named members:
```typescript
{
0: T0;
1: T1;
...
n: Tn;
}
```
When an array literal is contextually typed by a tuple type, each of the array literal expressions are contextually typed by the corresponding tuple element type, and the result is a tuple type:
```typescript
var t: [number, string] = [1, "hello"];
t = []; // Error
t = [1]; // Error
t = [2, "test"]; // Ok
t = ["test", 2]; // Error
t = [2, "test", true]; // Ok
```
When a value of a tuple type is indexed with a numeric constant, the resulting type is that of the corresponding type element. For example:
```typescript
var x: [number, string] = [1, "hello"];
var x0 = x[0]; // Type number
var x1 = x[1]; // Type string
var x2 = x[2]; // Type {}
```
A tuple type is assignable to a compatible array type. For example:
```typescript
var a1: number[];
var a2: {}[];
var t1: [number, string];
var t2: [number, number];
a1 = t1; // Error
a1 = t2; // Ok
a2 = t1; // Ok
a2 = t2; // Ok
```
Type inference works as expected for tuple types:
```typescript
function tuple2(item0: T0, item1: T1): [T0, T1] {
return [item0, item1];
}
var t = tuple2("test", true);
var t0 = t[0]; // string
var t1 = t[1]; // boolean
```
Next step is to support EcmaScript 6 style destructuring of objects, arrays, and tuples.