title: Typescript: Function return type that depends on value of string parameter
body: <p>I'd like to write types for a JavaScript library that creates an object of functions depending on a string that is passed to it.</p>
  
  <p>The function is supposed to be something like this:</p>
  
  <pre><code>function createResource(name: string): { /* How to write these types? */ } {
    return {
       [`create${name}`]: () =&gt; {},
       [`update${name}`]: () =&gt; {},
    }
  }
  </code></pre>
  
  <p>The idea is that given a string to a function (say "todo"), the function would return an object </p>
  
  <pre><code>{
    createTodo: (todo: Todo) =&gt; void,
    updateTodo: (todo: Todo) =&gt; void
  }
  </code></pre>