Repository: TypeScript
Issue: Variadic function argument not getting inferred correctly
Labels: Needs Investigation

# Bug Report
I am trying to create a function type where the args are some variadic number of generic args, `T`, and the last arg is an optional overrides variables: `overrides?: FetchQueryOptions<R>`, but the variadic args,`T`, are unable to be assigned to any type. See below for code example.

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

<!--
  What search terms did you use when trying to find an existing bug report?
  List them here so people in the future can find this one more easily.
-->
Generic functions variadic tuple type inference spread

### 🕗 Version & Regression Information

<!-- When did you start seeing this bug occur?

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to
  https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

If possible, please try testing the nightly version of TS to see if it's already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly

Note: The TypeScript Playground can be used to try older versions of TypeScript.

Please keep and fill in the line that best applies:
-->
- This is the behavior in every version I tried, and I reviewed the FAQ for entries

### ⏯ Playground Link

<!--
  A link to a TypeScript Playground "Share" link which shows this behavior

  The TypeScript Workbench can be used for more complex setups, try
  https://www.typescriptlang.org/dev/bug-workbench/

  As a last resort, you can link to a repo, but these will be slower for us to investigate.
-->
[Playground link with relevant code](https://www.typescriptlang.org/play?ts=4.3.5#code/JYOwLgpgTgZghgYwgAgGITAgFgRQK7QCeA8gA5jAD2IAzgDwBKAfMgN4BQyXyMG2qeEAgD8ALmQAKAJTIAvCwYBudgF927CAA9SlKGGShIsRCgCSAcQz4iAoYxYcudACrItkEABMayOCEIA2gC6TBKc3AB0UXBQAOY04gFREVAQNGDizgA0yJQAbtBQwJ5pYmh8uARQJORUtPZB4VLi6JiVRGQU1PTMymrsCN36sRgAqjTQAAqU6dbV4hZWVYS2CHTpRSCxLLKS4XgTUKae4hugsVnhOunH4iB4ALYARtCXXPmFxaUtFXM1XfUzlsmOxmuU2n9OnV6EDtnIHOFUmA8FAQGxwtweBVVuJpPDkAByGiUB4oTxwMBwUQE5AAamQAAMACSsA7QY4qBl0xks65gDkMt6Y5DJD5QIolGjhNQqRRAA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
interface FetchQueryOptions<R> {
    fetchFunc?: () => R;
}

export interface IGetQueryFunc<R> {
  <T extends any[]>(
    ...args: [...rest: T, overrides?: FetchQueryOptions<R>]
  ): FetchQueryOptions<R>;
}

const getUserPostQuery: IGetQueryFunc<string> = (
  userId: string,
  postId: number,
  overrides?: FetchQueryOptions<string>
): FetchQueryOptions<string> => {
  return {
      fetchFunc: () => 'some data:' + `${userId}` + `${postId}`,
      ...overrides
  }
};
```

### 🙁 Actual behavior
I am getting the below error:
```
Type '(userId: string, postId: string, overrides?: FetchQueryOptions<string> | undefined) => FetchQueryOptions<string>' is not assignable to type 'IGetQueryFunc<string>'.
  Types of parameters 'userId' and 'rest' are incompatible.
    Type '[...rest: T, overrides?: FetchQueryOptions<string> | undefined]' is not assignable to type '[userId: string, postId: string, overrides?: FetchQueryOptions<string> | undefined]'.
      Variadic element at position 0 in source does not match element at position 0 in target.(2322)
```
<!-- What happened, and why it was wrong -->

### 🙂 Expected behavior
I expect the `...rest: T` to be correctly inferred as `[string, number]`. and `...args` to be inferred as `[string, number, FetchQueryOptions<string> | undefined]`
<!-- What you expected to happen instead, and why -->