title: Dynamic types in typescript
body: <p>How would one define the return type of the <code>fn</code> function below?</p>
  <pre class="lang-js prettyprint-override"><code>const fn = (propName1: string, propName2: string) =&gt; {
    return { 
     [propName1]: () =&gt; true 
     [propName2]: () =&gt; 'abc'
    }
  }
  const x = fn('customProp1', 'customProp2')
  console.log(x.customProp1)
  console.log(x.customProp2)
  </code></pre>
  <p>e.g.</p>
  <pre class="lang-js prettyprint-override"><code>type FN = (propName: string)=&gt; {
    [propName1]: ()=&gt;true
    [propName2]: ()=&gt;string
  }
  </code></pre>
  <p>This is for two custom methods, but ideally the solution should allow for any number of custom methods and properties.</p>