Dictionary in Typescript based on arrays of generic types.

Typescript is definitely a promising language (at the time of writing the last release is 1.6). Unfortunately there are still some missing facilities. This is especially true for those who are used to work with strongly typed programming languages like C#.

One of this “missing facilities” is the dictionary type.

Unless you go with ECMAScript 6 and its map object, the classical solution is to use an object as a map:

map: { [key: string]: U } = { };

Instead of this, I’ve decided to take a different approach and to build my own dictionary type.
Continue reading