title: Extract a key/value object type from the properties of an array of objects in Typescript
body: <p>I have a constant array of objects that use the same properties. Something like this:</p>
  <pre><code>const allData = [{
    name: 'info', content: Info
  },{
    name: 'other', content: Other
  },{
    ...
  }];
  </code></pre>
  <p>Now I want to create a variable that after some other code is run, will map these into an object where the keys are the strings of the <strong>name</strong> property and the values are instances of the <strong>content</strong> property. Given that, I want to know how I can define such a type in Typescript that would basically extract those properties from my constant so that it becomes like this in the end:</p>
  <pre><code>Type ContentInstances = {
    info: Info,
    other: Other 
    ...
  }
  </code></pre>
  <p>Is there such a way using typeof and other things on Typescript to achieve this dynamically based on <strong>allData</strong> constant?</p>
  <p><strong>EDIT</strong>
  Basically at a later stage, I will have something like this:</p>
  <pre><code>let myVar: ContentInstances;
  ...
  myVar = allData.reduce((obj, value) =&gt; {
    obj[value.name] = new value.content(customParam);
    return obj;
  }, {})
  </code></pre>