title: Typescript type from an array
body: <p>Say I have:</p>
  
  <pre><code>const generate = (array: string[]) =&gt; {
     const obj: any = {};
     array.map(a =&gt; a.toUpperCase()].forEach(a =&gt; obj[a] = a);
  
     return obj;
  }
  </code></pre>
  
  <p>So that I can do:</p>
  
  <pre><code>const constants = generate(['foo', 'bar']);
  constants.FOO;
  constants.BAR;
  </code></pre>
  
  <p>Is there anyway to define the type so that <code>constants.BAZ</code> for example errors out? </p>