title: string or number dictionary type parameter
body: <p>I have this function:</p>
  
  <pre><code>interface NumDict&lt;T&gt; {
    [key : number] : T
  }
  
  export function mapNumDictValues&lt;T,R&gt;(dict: NumDict&lt;T&gt;, f: (v: T, key?: number) =&gt; R): NumDict&lt;R&gt; {
    let emptyDict : NumDict&lt;R&gt; = {};
    return Object.keys(dict).reduce((acc, key) =&gt; {
      const keyInt = parseInt(key);
      acc[keyInt] = f(dict[keyInt], keyInt);
      return acc;
    }, emptyDict);
  }
  </code></pre>
  
  <p>Now I would like it to work for string indexed dictionaries as well as number indexed dictionaries, e.g. something like:</p>
  
  <pre><code>function mapDictValues&lt;K extends string|number,T,R&gt;(obj: {[id: K]: T}, f: (v: T, key?: K) =&gt; R): {[id: K]: R} {
  </code></pre>
  
  <p>However, this gets me this error:</p>
  
  <pre><code>error TS1023: An index signature parameter type must be 'string' or 'number'.
  </code></pre>
  
  <p>Is there a way?</p>