TypeScript hashtables and dash keys

Is it possible to declare a hash table that contains dash keys in TypeScript?

Here is the code I tried:

export interface ImapMessageHeader { 'mime-version': string[]; received: string[]; [index: string]: string[]; } 

From which I get the following error:

Expected identifier in property declaration

The last declaration defining the type of index allows me to call any string key, but I cannot explicitly determine which ones I want to use.

Thanks!

+6
source share
2 answers

This works for me in TypeScript 0.9.5. The problem is also marked as closing .

 interface Foo { "a-1": string; } var f: Foo = { "a-1": "hello" }; 
+6
source

Names of quoted properties in interface declarations and type literals are not yet supported, but I believe that they will be added in a future version.

+3
source

All Articles