title: Assigning properties in an object by iterating through its keys
body: <p>I have an enum:</p>
  <pre><code>enum REPORT_PARAMETERS {
      DEFECT_CODE = 'DEFECT_CODE',
      ORGANIZATION = 'ORGANIZATION'
  }
  </code></pre>
  <p>And I have an object and a map of functions, which use this enum as keys:</p>
  <pre><code>interface Form {
    [REPORT_PARAMETERS.DEFECT_CODE]: number;
    [REPORT_PARAMETERS.ORGANIZATION]: string;
  }
  
  const form = {
    [REPORT_PARAMETERS.DEFECT_CODE]: 1,
    [REPORT_PARAMETERS.ORGANIZATION]: '1'
  }
  
  const formMappers: {
      [key in REPORT_PARAMETERS]: () =&gt; Form[key];
  } = {
    [REPORT_PARAMETERS.DEFECT_CODE]: () =&gt; 123,
    [REPORT_PARAMETERS.ORGANIZATION]: () =&gt; '123'
  }
  </code></pre>
  <p>Then I want to iterate enum to map form:</p>
  <pre><code>const reports: REPORT_PARAMETERS[] = [
       REPORT_PARAMETERS.DEFECT_CODE,
      REPORT_PARAMETERS.ORGANIZATION
  ]
  
  reports.forEach((type) =&gt; {
    // At this point I assume that 'type' is a specific value of enum,
    // so I try to use this value to index both objects, but it doesn't work
    form[type] = formMappers[type]();
  })
  </code></pre>
  <p>Here is <a href="https://www.typescriptlang.org/play?#code/KYOwrgtgBASgogBQPIwCoH0EEEZYLJypwwDKUA3gLABQUdUAInAGJwDCGbSTUAvFAHImrDui5MBAGhr0oKAOJYAcgEkAWllQqkSvoIXL1m7UoE0AvjRoBLEABdgAJwBmAQwDGwKMwD2j6FS0UADa8MhomDj4hMQkAHTC7JzccAC6AFxQ4BAARk4A3DIhYSgY2LgERKRxBqoaWjoZUADOdo62AOaF1JbUNO4%20IK1Qzn7Q-IF0oYilkRUx1Ymi4mmZAIzSQdPhZVGVsTUwinXGjZkCa2Y9VtQDQ3YjY3iuAA4vTs2Zk-TBANbAAE8oLZYDMIuVolUSE0ABQASj4AD5vGM-oDUt1zHpvttZhD9osWEkxClYQjeMi1gAmADMmymJXBewW8VqRgaSjJSME1JpV16-UGw0cwBefjsn1BOzmkNiwVSemCRXojN28yhCSJyxS9JVYLVsuqbPqJhoqRuIrFjglcVGjjgHgAFjCYXYAe9ycjvnaIME3e8Ffwfc83h8-e7gKl4Zi4UA" rel="nofollow noreferrer">TypeScript Playground</a> to see it in action</p>