title: Can I reuse the parameter definition of a function in Typescript?
body: <p>I would like to capture the compile-time parameter structure of a function that I can reuse in multiple function definitions with similar signatures.  I think this might be along the lines of <a href="https://github.com/Microsoft/TypeScript/issues/4130" rel="nofollow noreferrer">this TS issue</a> or maybe more specifically <a href="https://github.com/Microsoft/TypeScript/issues/5331" rel="nofollow noreferrer">this one</a>, but I'm not sure my use case necessarily lines up with those proposals, so it <em>might</em> be possible to do this in current Typescript.  What I'm trying to do is this:</p>
  
  <pre><code>type FooArgs = ?{x: string, y: number}?; // syntax?
  class MyEmitter extends EventEmitter {
    on(event: "foo", (...args: ...FooArgs) =&gt; void): this;
    emit(event: "foo", ...args: ...FooArgs): boolean;
  }
  </code></pre>
  
  <p>This might not be the smartest way to do it.  I would also be happy to learn about some other way to "copy" one method's argument list to another:</p>
  
  <pre><code>class MyEmitter extends EventEmitter {
    emit(event: "foo", x: string, y: number): boolean;
    on(event: "foo", (argumentsof(MyEmitter.emit)) =&gt; void): this;
  }
  </code></pre>
  
  <p>but I don't believe any such keyword / builtin exists.</p>
  
  <p>As an aside, I have tried an approach similar to the early examples in <a href="https://medium.com/@bterlson/strongly-typed-event-emitters-2c2345801de8" rel="nofollow noreferrer">this article</a> but even with all the complex type operations described later, that approach only allows for events that emit zero or one arguments.  I'm hoping that, for this limited use case, there might be a smarter way.</p>