Repository: TypeScript
Issue: Inaccurate Intellisense / Suggestions with Function Overloads
Labels: Suggestion,Help Wanted,Domain: Completion Lists,Experience Enhancement

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version:
Version: 1.69.1 (system setup)
Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
Date: 2022-07-12T08:21:24.514Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Windows_NT x64 10.0.19044

Steps to Reproduce:
1. Go to [this playground](https://www.typescriptlang.org/play?ts=4.7.4&ssl=25&ssc=67&pln=1&pc=1#code/GYVwdgxgLglg9mABAEzgZTgWwKZQBYxgDmAPACoCeADtotgB5TZjIDOicARgFbbQA0iANLYKdRszaIA1qLjBElGgD4AFAChEiGE0wAuRdWz9NiAHQXZFVgZEUA2gF11ASgMA3ODGQBudetBIWAQUdCxcAmJyI3EmFnYuXgFhUVjJdit5QxUNLR1sTBts7CcTLQszKyK7J1cPL19-QOh4JFQMHHxCUiVaBjipRL4oQTs0+Jk5BV61U3zMAHkAJwBJXSLesvNLUWrRWpdEAG9TAHpTjkwdJmREYDglxE4l7HcdCnUAX38oGIAxOBwRAAXmOpgAhgYwCBMJxsEs-FpOFCYXCEaYIAZWFAlt0-J8-OoIAhsYh6CDQh0It1VEdEJDEABGQTIxAAJkEmMQACJuYhPvT2AC4IJueDuaLOBKeRBuS4-MSwKSxKD2uEusRVPY6QzmU8DBzEFzefzHILEMLSjzxaLZfL1EA) and/or create a new TypeScript file with the code snippet shared below
2. After `"c"` on the last line, type `, "i"`
3. Note the intellisense and suggestions

Apologies, there's probably a better title for this issue...

I thought this might be a better issue for Monaco, but their issue template said that if I could recreate the issue in VS Code to open the issue here. Maybe this should be a TS issue instead since its reproducible in the playground as well? However, the TypeScript seems to be working fine, it's just the intellisense that seems to be confused.

Take the following code:

```ts
function doSomething<Type extends object, Key extends keyof Type>(
  item: Type,
  ...keys: Key[]
): void;

function doSomething<Type extends object, Key extends keyof Type>(
  items: Type[],
  ...keys: Key[]
): void;

function doSomething<Type extends object, Key extends keyof Type>(
  itemOrItems: Type,
  ...keys: Key[]
) {
  // omitted for brevity
}

type Foo = {
  a: number;
  b: number;
  c: string;
};

const x = doSomething({ a: 1, b: 2, c: "" } as Foo, "a", "b", "c");
const y = doSomething([{ a: 1, b: 2, c: "" }] as Foo[], "a", "c");
```

When spreading arguments into the function corresponding with the second overload, the intellisense provides inaccurate suggestions and incorrectly infers `...keys` as `(keyof Foo[])[]` when it should actually be `(keyof Foo)[]`:

![image](https://user-images.githubusercontent.com/18563015/193386129-02da0c70-2262-4e7d-bfa5-36c847323d18.png)

Again, note that TypeScript is working as expected, and accepting any of the suggestions provided by the intellisense will result in a type error.