title: How to restrict keyof T to number fields? where T[keyof T] is number
body: <p>I want to restrict field parameter in following function:</p>
  
  <pre><code>function sum&lt;T&gt;(source: T[], field: keyof T) {
     for(const item of source) {
  
     }
  }
  </code></pre>
  
  <p>so that <code>item[field]</code> is always a number..</p>
  
  <p>Is it possible?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Additionally, how to restring non generic function parameter:</p>
  
  <p>function foo(field: keyof MyObj){
  }</p>
  
  <p>so that</p>
  
  <pre><code>interface MyObj { name: string, value: number; }
  foo("name"); // throws compiler error
  </code></pre>