title: Typescript: Generic type of method params to match type of callback function params
body: <p>I'm trying to make a class that accepts a function in the constructor. The function can have arguments of any type. Then I want to put a method on the class that accepts that same arguments as function parameter, as it will be a wrapper around this callback. Here's a simplified example to show what I'm trying to do</p>
  <pre><code>interface Options&lt;T&gt; {
     callbackFn(...x: any[]) =&gt; Promise&lt;T&gt;
  }
  
  class ExampleClass&lt;T&gt; {
    private options: Options&lt;T&gt;;
    result: T;
  
    constructor(options: Options&lt;T&gt;) {
      this.options = options;
    }
  
    async wrapperFn(...x: any[]) {
      // Do some stuff before the callback
  
     this.result = await this.options.callbackFn(x)
      
     // Do some stuff after
    }
  }
  
  const example = new ExampleClass&lt;string&gt;({
    callbackFn: (a: string, b:string) =&gt; new Promise((res) =&gt; {
      res(a + b);
    })
  });
  
  example.wrapperFn(&quot;foo&quot;, &quot;bar&quot;)
  </code></pre>
  <p>This is basically the way I have it now, and it works but it obviously doesn't enforce the types of the params of wrapperFn which isn't ideal. Is there any way to do something like this?</p>