title: How to create object keys from array values in typescript
body: <p>How to type following function in typescript so I get autocompletion &amp; error prevention.</p>
  <p>Using Typescript 4.7.4</p>
  <pre><code>// reference fn
  function doSomething(list) {
  
      const data = {};
  
      list.map(item =&gt; {
          data[item] = 'value type string|number|bool|null'   
      });
  
      return data;
  }
  
  // calling it like
  const data = doSomething([
      'phone_number',
      'customer_email'
  ]);
  
  // get IDE autocomplete here (for only properties inside data)
  console.log(data.phone_number);
  console.log(data.customer_email);
  
  // typescript yell when try to access invalid properties
  console.log(data.phone_numbersss);
  </code></pre>