TypeScript Objects as Dictionary types as in C#-open source projects Microsoft/TypeScript

Ken Smith

You can do this in an array in JavaScript now, and so hence in TypeScript.

class User {
    constructor(public name:string){}
}

var users: User[] = [];

users['[email protected]'] = new User('Bob');  
alert(users['[email protected]'].name);

TS doesn’t yet support Generics, so you can’t use anything besides a string or an integer as an index into the array, but using a string as an index is probably the most typical use for a dictionary anyway.