title: Get return type of class method via method name in Typescript
body: <p>Let's say we have a class:</p>
  <pre><code>class Foo {
    var1: string = 'var1';
    var2: string = 'var2';
  
    hello(request: A): Promise&lt;B&gt; {  }
  
    world(request: C): Promise&lt;D&gt; {  }
  }
  </code></pre>
  <p>I want to implement the function that executes a method of the instance of <code>Foo</code>:</p>
  <pre><code>const foo = new Foo();
  const executeFoo = (methodName: string, firstParam: any) =&gt; { // &lt;- I'm stuck in this arrow function.
    return foo[methodName](firstParam);
  };
  
  executeFoo('hello', testParam); // testParams is type of A, then return type should Promise&lt;B&gt;.
  executeFoo('world', testParam2); // testParams2 is type of C, then return type should Promise&lt;D&gt;.
  </code></pre>
  <p>Is there a way to define the type of <code>executeFoo</code>? I'm totally confused about how to resolve this problem.</p>