<p dir="auto">The compiler requires an index signature parameter to be "string" or "number" specifically, and doesn't allow type aliases.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type CustomId = string;

interface Works {
    [customId: string]: string;
}
interface DoesNotWork {
    [customId: CustomId]: string;
}
// An index signature parameter type must be 'string' or 'number'."><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">CustomId</span> <span class="pl-c1">=</span> <span class="pl-smi">string</span><span class="pl-kos">;</span>

<span class="pl-k">interface</span> <span class="pl-smi">Works</span> <span class="pl-kos">{</span>
    <span class="pl-kos">[</span><span class="pl-s1">customId</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-k">interface</span> <span class="pl-smi">DoesNotWork</span> <span class="pl-kos">{</span>
    <span class="pl-kos">[</span><span class="pl-s1">customId</span>: <span class="pl-smi">CustomId</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-c">// An index signature parameter type must be 'string' or 'number'.</span></pre></div>
<p dir="auto">Shouldn't CustomId be allowed there?</p>
<p dir="auto">According to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="110547529" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/5185" data-hovercard-type="pull_request" data-hovercard-url="/microsoft/TypeScript/pull/5185/hovercard" href="https://github.com/microsoft/TypeScript/pull/5185">#5185</a>, string literal types are assignable to plain strings. Given the following type definition:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type NodeType = &quot;IfStatement&quot;
              | &quot;WhileStatement&quot;
              | &quot;ForStatement&quot;;"><pre class="notranslate"><span class="pl-k">type</span> <span class="pl-smi">NodeType</span> <span class="pl-c1">=</span> <span class="pl-s">"IfStatement"</span>
              <span class="pl-c1">|</span> <span class="pl-s">"WhileStatement"</span>
              <span class="pl-c1">|</span> <span class="pl-s">"ForStatement"</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Both these assignments are valid:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const nodeType1: NodeType = &quot;IfStatement&quot;;
const nodeType2: string = nodeType1;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">nodeType1</span>: <span class="pl-smi">NodeType</span> <span class="pl-c1">=</span> <span class="pl-s">"IfStatement"</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">nodeType2</span>: <span class="pl-smi">string</span> <span class="pl-c1">=</span> <span class="pl-s1">nodeType1</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">However, string literal types currently can't be used as index signature parameter types. Therefore, the compiler complains about the following code:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let keywords: { [index: NodeType]: string } = {
    &quot;IfStatement&quot;: &quot;if&quot;,
    &quot;WhileStatement&quot;: &quot;while&quot;,
    &quot;ForStatement&quot;: &quot;for&quot;
};

// error TS1023: An index signature parameter type must be 'string' or 'number'."><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">keywords</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">index</span>: <span class="pl-smi">NodeType</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span> <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
    <span class="pl-s">"IfStatement"</span>: <span class="pl-s">"if"</span><span class="pl-kos">,</span>
    <span class="pl-s">"WhileStatement"</span>: <span class="pl-s">"while"</span><span class="pl-kos">,</span>
    <span class="pl-s">"ForStatement"</span>: <span class="pl-s">"for"</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-c">// error TS1023: An index signature parameter type must be 'string' or 'number'.</span></pre></div>
<p dir="auto">Shouldn't that scenario be supported, given that string literal types are assignable to strings?</p>
<p dir="auto">/cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/DanielRosenwasser/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/DanielRosenwasser">@DanielRosenwasser</a></p>