title: Is it possible for TypeScript to infer keys from a dynamic object?
body: <p>What I'm trying to achieve here is intellisense/autocomplete for an object that's been generated from an array - something like an Action Creator for Redux, an array of strings (<code>string[]</code>) that can be reduced to an object with shape <code>{ [string]: string }</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>const a = ['ONE', 'TWO', 'THREE'];
  
  const b = a.reduce((acc, type) =&gt; ({ ...acc, [type]: type }), {});
  
  console.log(b);
  // Output: b = { ONE: 'ONE', TWO: 'TWO', THREE: 'THREE' };
  </code></pre>
  
  <p>I've managed to get TypeScript to understand that much, using the below. TypeScript understands that the keys are strings, but does not know what they are.</p>
  
  <pre><code>interface ITypesReturnObject { [s: string]: string }
  </code></pre>
  
  <p>Has anyone worked out a way to inform TypeScript that the keys on the object are equal to the strings in the array?</p>
  
  <p>Any help would be greatly appreciated.</p>