Map/Reduce Tuples to Tuples in Typescript

If you use map/reduce to process your Tuples, you will find it errors out in Typescript.

type Point = [number, number];

const point: Point = [0, 1];

const shifted: Point = point.map(a => a + 1);

You will need to cast your result as a type.

const shifted: Point = point.map<Point>(a => a + 1);

This method allows you to check the result as a Point. The type checks properly.

const shifted: Point = point.map(a => a + 1) as Point;

Casting the result as a Tuple also works.