title: Override function with both list and object as argument in Typescript
body: <p>Can someone explain me why the first override's signature is not compatible with the implementation signature?</p>
  
  <p>I want to have a function that takes both standard list arguments as well as "named" arguments in the form of an object.</p>
  
  <p>I saw it done e.g. in <a href="https://github.com/tannerlinsley/react-query" rel="nofollow noreferrer"><code>react-query</code></a>'s <code>useQuery</code> hook. I had a look at their type definitions and they seem to be doing pretty much the same as I do.</p>
  
  <p>Here's my attempt:</p>
  
  <pre class="lang-js prettyprint-override"><code>interface Args {
    readonly a: string;
    readonly b?: boolean;
  }
  
  function foo(args: Args): number;
  function foo(...args: [Args['a'], Args['b']?]): number;
  function foo(a: string, b?: boolean): number { /* IMPLEMENTATION */ }
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p><code>This overload signature is not compatible with its implementation signature. ts(2394)</code></p>
  </blockquote>
  
  <p>error.</p>
  
  <p>I get that object as an argument is something different than a list of arguments, so I don't really get how it actually works in <code>react-query</code>.</p>
  
  <p>From inspection of their code however, they seem to define types (in <code>*.d.ts</code> file) of their <code>useQuery</code> export in similar way (see <a href="https://github.com/tannerlinsley/react-query/blob/master/types/index.d.ts" rel="nofollow noreferrer"><code>types/index.d.ts</code></a>) and the exported implementation seems to be just spreading the arguments:</p>
  
  <p><a href="https://github.com/tannerlinsley/react-query/blob/master/src/useQuery.js" rel="nofollow noreferrer"><code>src/useQuery.js</code></a>:</p>
  
  <pre><code>...
  export function useQuery(...args) {
  ...
  </code></pre>
  
  <p>As spread is not possible in TS if the argument is not of an Array type, I'm not sure how to simulate this behavior.</p>