Is it possible to declare a hashtable which includes keys with a dash in TypeScript?
Here's the code i've tried:
export interface ImapMessageHeader {
'mime-version': string[];
received: string[];
[index: string]: string[];
}
From which i receive the following error:
Expected identifier in property declaration
The last declaration defining the index type allows me to call any string key, but i can't explicitly define the ones i want to use.
Thanks!
This works for me in TypeScript 0.9.5. The issue is marked as close too.
interface Foo
{
"a-1": string;
}
var f: Foo = { "a-1": "hello" };
Quoted property names in interface declarations and type literals aren't supported yet, but I believe they will be added in a future release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With