title: Typescript type string is not assignable to type keyof when I get value from object
body: <p>Could someone explains why in the example code below typescript gives the error message &quot;const key: string
  Argument of type 'string' is not assignable to parameter of type 'keyof Condition&quot;</p>
  <pre class="lang-ts prettyprint-override"><code>interface Condition {
      GOOD: 'GOOD';
      BAD: 'BAD';
      NONE: 'NONE';
  }
  
  const ObjWithAllCondition: Condition = {
      GOOD: 'GOOD',
      BAD: 'BAD',
      NONE: 'NONE',
  };
  
  interface Result {
      condition: keyof Condition;
      count: number;
  }
  
  const getKeyValue = &lt;T extends Condition, K extends keyof T&gt;(obj: T, key: K) =&gt; obj[key];
  
  const getResult = (): Result[] =&gt; {
      const result = [];
      for (const key in ObjWithAllCondition) {
          result.push({
              condition: getKeyValue(ObjWithAllCondition, key), // this is error
              count: 1,
          });
      }
  
      return result;
  };
  </code></pre>