As said in the Handbook, you can declare a custom array interface with string or number index:
interface StringArray {
[index: number]: string;
}
So I made this:
interface EventRegistrations {
[index:string]:ListenerEntry[];
}
problem is simple: how can I initialize such a thing?
Here is what I tried and the error message provided (using PhpStorm 2016.1 with tsc 1.8.7):
foo:EventRegistrations = [];
Type 'undefined[]' is not assignable to type 'EventRegistrations'
foo:EventRegistrations = [[]];
Type 'undefined[][]' is not assignable to type 'EventRegistrations'
foo:EventRegistrations = [index:string]:ListenerEntry[];
Syntax error (expected , where first : is)
foo:EventRegistrations = [string]:ListenerEntry[];
Syntax error (expected ; where : is)
foo:EventRegistrations = new EventRegistrations();
Syntax error (cannot find name 'EventRegistrations')