<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="enum Foo { }

var fooMap: { [foo: Foo]: string } // =&gt; error TS1023: An index signature parameter type must be 'string' or 'number'."><pre class="notranslate"><span class="pl-k">enum</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>

<span class="pl-k">var</span> <span class="pl-s1">fooMap</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">foo</span>: <span class="pl-smi">Foo</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span> <span class="pl-kos">}</span> <span class="pl-c">// =&gt; error TS1023: An index signature parameter type must be 'string' or 'number'.</span></pre></div>
<p dir="auto"><a href="http://www.typescriptlang.org/Playground#src=enum%20Foo%20%7B%20%7D%0D%0A%0D%0Avar%20fooMap%3A%20%7B%20%5Bfoo%3A%20Foo%5D%3A%20string%20%7D" rel="nofollow">play</a></p>
<hr>
<p dir="auto">Enums are internally numbers, so this should be able to compile fine.</p>
<p dir="auto">Typescript requires that enums have number value types (hopefully soon, this will also include string value types).</p>
<p dir="auto">Attempting to use an enum as a key type for a hash results in this error: "Index signature parameter type much be 'string' or 'number' ".-- An enum is actually a number type.-- This shouldn't be an error.</p>
<p dir="auto">Enums are a convenient way of defining the domain of number and string value types, in cases such as</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export interface UserInterfaceColors {
    [index: UserInterfaceElement]: ColorInfo;
}
export interface ColorInfo {
    r: number;
    g: number;
    b: number;
    a: number;
}
export enum UserInterfaceElement {
    ActiveTitleBar = 0,
    InactiveTitleBar = 1,
}"><pre class="notranslate"><code class="notranslate">export interface UserInterfaceColors {
    [index: UserInterfaceElement]: ColorInfo;
}
export interface ColorInfo {
    r: number;
    g: number;
    b: number;
    a: number;
}
export enum UserInterfaceElement {
    ActiveTitleBar = 0,
    InactiveTitleBar = 1,
}
</code></pre></div>