title: How do you specify the type of a value in a keyof declaration?
body: <p>I have a simple sum function that takes two arguments, an iterable data structure and a key whose value will be summed: </p>
  
  <pre><code>const sum&lt;T, K extends keyof T&gt;(arr: T, key: K) =&gt; {
    return arr.reduce((acc, el) =&gt; {
      acc += el[key]
      return acc
    }, 0)
  }
  </code></pre>
  
  <p>const data = [{value: 3}, {value: 1}, {value: 2}]</p>
  
  <p>sum(data, 'value')</p>
  
  <p>I want to be able to tell typescript that the key's value is of type number. How can I do this in Typescript?</p>