title: How do I extract all methods' ReturnType<T> of class (while ReturnType<T> and usage seem static)
body: <p>I've gone through the docs at typescript: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypet" rel="nofollow noreferrer">https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypet</a></p>
  <p>I've searched on here and found two cases of <code>ReturnType&lt;T&gt;</code>, but they all seem statically written out, and I know there has to be a way to dynamically read out the response data type.</p>
  <p>Example of <em>close to idea</em>:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/62325850/rewrite-error-catching-higher-order-function-to-catch-async-errors/62326380#62326380">Rewrite error catching higher order function to catch async errors?</a></li>
  <li><a href="https://stackoverflow.com/questions/61358692/type-that-converts-all-the-methods-on-an-interface-to-return-promises/61358913#61358913">Type that converts all the methods on an interface to return promises</a></li>
  <li><a href="https://stackoverflow.com/questions/49429068/is-modifying-methods-return-type-by-decorator-possible">Is modifying method&#39;s return type by decorator possible?</a></li>
  </ul>
  <p>For example:</p>
  <pre><code>class Idea1 {
      one() { return &quot;one&quot;; }
      two() { return &quot;two&quot;; }
  }
  class Idea2 {
      do() { return { message: &quot;do-one&quot; }; }
      process() { return { shouldDo: true }; }
  }
  
  // similar to the example I've seen
  const i1 = new Idea1();
  declare type R1 = ReturnType&lt;typeof i1.one&gt;; // string
  
  const i2 = new Idea2();
  type R2 = ReturnType&lt;typeof i2.do&gt;;  // { message: string }
  </code></pre>
  <p>I know the &quot;typical&quot; way is to extract it via type, but how could I submit a class and get a list of return types?</p>
  <p>like (with the classes above)</p>
  <pre><code>//what I'd love to see
  getReturnTypes(Idea1) // [string, string]
  
  //but I could always new it up first then pass it, and then passed in
  getReturnTypes(new Idea2()) // [{message: string}, {shouldDo: boolean}]
  </code></pre>
  <p><strong>the main thing is that I want to be able to get method return information</strong></p>
  <p>I'm having a terrible time trying to understand how to programmatically work through this flow. I see the assignment for the type being at a high level on the page, so it makes it odd to write out a new type for each method of class as another type ReturnType.</p>
  <p>Help please!</p>