title: Type 'string' cannot be used to index type 'T'.ts(2536)
body: <p>I'm getting the above error on <code>result[key]</code> in</p>
  
  <pre class="lang-js prettyprint-override"><code>type DataType = Record&lt;string, number&gt;
  export function getDifference&lt;T extends DataType&gt;(data1: T, data2: T): T {
    const keys = Object.keys(data1)
    return keys.reduce&lt;T&gt;((result, key) =&gt; {
      result[key] = data1[key] - data2[key]
      return result
    }, {})
  }
  </code></pre>
  
  <p>How do I get rid of it while still returning an generic type <code>T</code> so that the consuming functions still receive the correct type (instead of simply changing <code>T</code> to <code>DataType</code>).</p>