<p dir="auto">At the moment, index signature parameter type must be string or number.<br>
Now that Typescript supports String literal types, it would be great if it could be used for index signature parameter type as well.</p>
<p dir="auto">For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="type MyString = &quot;a&quot; | &quot;b&quot; | &quot;c&quot;;

var MyMap:{[id:MyString] : number} = {};
MyMap[&quot;a&quot;] = 1; // valid
MyMap[&quot;asd&quot;] = 2;   //invalid"><pre class="notranslate"><code class="notranslate">type MyString = "a" | "b" | "c";

var MyMap:{[id:MyString] : number} = {};
MyMap["a"] = 1; // valid
MyMap["asd"] = 2;   //invalid
</code></pre></div>
<hr>
<p dir="auto">It would be also useful if it could also work with Enums. For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="enum MyEnum {
    a = &lt;any&gt;&quot;a&quot;,
    b = &lt;any&gt;&quot;b&quot;,
    c = &lt;any&gt;&quot;c&quot;,
    d = &lt;any&gt;&quot;d&quot;,
}

var MyMap:{[id:MyEnum] : number} = {};
MyMap[MyEnum.a] = 1; // valid
MyMap[&quot;asd&quot;] = 2;   //invalid

var MyMap:{[id:MyEnum] : number} = {
    [MyEnum.a]:1,   // valid
    &quot;asdas&quot;:2,  //invalid
}"><pre class="notranslate"><code class="notranslate">enum MyEnum {
    a = &lt;any&gt;"a",
    b = &lt;any&gt;"b",
    c = &lt;any&gt;"c",
    d = &lt;any&gt;"d",
}

var MyMap:{[id:MyEnum] : number} = {};
MyMap[MyEnum.a] = 1; // valid
MyMap["asd"] = 2;   //invalid

var MyMap:{[id:MyEnum] : number} = {
    [MyEnum.a]:1,   // valid
    "asdas":2,  //invalid
}
</code></pre></div>
<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>