Repository: TypeScript
Issue: TS2769 : Function.bind
Labels: Bug

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms
function bind

<!--
  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.
-->

### 🕗 Version & Regression Information
TypeScript 4.1 & 4.2-beta

<!-- 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:
-->

### ⏯ Playground Link
[playground](https://www.typescriptlang.org/play?#code/C4TwDgpgBAYgrgOwMYGcoF4oG8BQV9QBmAlgE4rBQAUAbgIYA2cEAXFBacQgOYCUbNAPbEAJgG48BFBCSCEI6vSasoCOAFsARhFL8oQ0RIC+OHKEhQAysEGlomXASiz164pQA8AOTrroEAA9gCHk0AGsIEEFCWERUAD5qSSd8BF8VHz8AGmSUgDoCulJuFDYABSL04PIPeGQUAG1MiABdeNy9A3EcEzNwaDqkKG90qEDg0KgIqJjBlETMKlyCvKKS8sq-apRauMbmtpxeDESuiRwRGQYi6FkECnYbOzZrWwhzwjjgYjlnQVd3CM-GMgiEROFItFYvVElQ0n42M09IMgRBEo4CAB6TFjUikWy5OzAOCkBCPN55FxuYB5TRcERURCXEgICAiLKqdK8YymT7Ib6-KnuABMqJBE3BU0hsz2sPhGS5bBRzXRhIgxNJRC+PzJVBWa1KUAqpCqOh2yvS8XixwxKSg2L+eJkwFyTgoFKFwDh6Q5+uKKG5uRMRiAA)

<!--
  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.
-->
### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
type Funcs = {
    first (value: string): void;
    second (value: number): void;
}

type Store = {
    commit <Name extends keyof Funcs> (
        name: Name,
        ...args: Parameters<Funcs[Name]>
    ): void;
}

type Func <Name extends keyof Funcs> = (
    ...args: Parameters<Funcs[Name]>
) => void;

declare const store: Store;

function commit<Name extends keyof Funcs> (name: Name): Func<Name> {
    // error
    return store.commit.bind(undefined, name);
}

function commit2<Name extends keyof Funcs> (name: Name): Func<Name> {
    return function (...args: Parameters<Func<Name>>) {
        // correct
        store.commit(name, ...args);
    }
}
```

### 🙁 Actual behavior
```
(method) commit<Name extends keyof Funcs>(name: Name, ...args: Parameters<Funcs[Name]>): void
No overload matches this call.
  Overload 1 of 6, '(this: (this: undefined, arg0: Name, ...args: [value: string] | [value: number]) => void, thisArg: undefined, arg0: Name): (...args: [value: string] | [value: number]) => void', gave the following error.
    The 'this' context of type '<Name extends keyof Funcs>(name: Name, ...args: Parameters<Funcs[Name]>) => void' is not assignable to method's 'this' of type '(this: undefined, arg0: Name, ...args: [value: string] | [value: number]) => void'.
      Types of parameters 'args' and 'args' are incompatible.
        Type '[value: string] | [value: number]' is not assignable to type 'Parameters<Funcs[Name]>'.
          Type '[value: string]' is not assignable to type 'Parameters<Funcs[Name]>'.
  Overload 2 of 6, '(this: (this: undefined, ...args: Name[]) => void, thisArg: undefined, ...args: Name[]): (...args: Name[]) => void', gave the following error.
    The 'this' context of type '<Name extends keyof Funcs>(name: Name, ...args: Parameters<Funcs[Name]>) => void' is not assignable to method's 'this' of type '(this: undefined, ...args: Name[]) => void'.
      Types of parameters 'name' and 'args' are incompatible.
        Type 'Name[]' is not assignable to type '[name: Name, ...args: Parameters<Funcs[Name]>]'.
          Target requires 2 element(s) but source may have fewer.(2769)
```

### 🙂 Expected behavior
The function `commit` works correctly as the function `commit2`. I'm a bit confused and sorry if this bug has been reported.