Repository: TypeScript
Issue: Union of functions with all-optional rest parameters is not callable with no arguments.
Labels: Suggestion,Experience Enhancement

# Bug Report

<!--
  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.
-->
* Argument of type '[]' is not assignable to parameter of type
* optional generic rest parameters union not callable

### 🕗 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 (3.3.3 - 4.8.0-beta), and I reviewed the FAQ for entries about this quite esoteric issue.

### ⏯ 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.8.0-beta#code/PTAEGEHsDsBcCcCWA3ApgE1AMwK7QMayIyiLSiTzqryiySlzyTo76qgDmq0Ni+oeKgDOsUAAcAhvEkBbVLBrCAULgJESsyQGtUAMWgAeACoBBeJ2GhUAD0XR0VydACeAbQC6APgAUWaABcoD4AdGHSlkFmFsIAlKAAvF6gzi6xQaHhMVHmlvFJoKJI0JygAN7KoFWCCjjw5JkhEXGJyQBSAMoA8gByIUVknIhYLn7Qjc2xsQDcygC+ysr4MKLYkAwJoFq6Bj4+kgD8QdA4sgBGNPnJ+6AHB6AADPEA1KAALABMM0srYmfSiS2On04x8ZyOhQQgyuwXBIQANjxOLAABa3e5PUCvT7fZQgUAAdUo2mEAR+0FWWHWACURDh4bAggMSoCqZAfN9lhS-tJacJ6YzIcVSpt-vAOdNQIt8UT4CSgvhJKJBnQGKiOFz8EJFHQXOIRGSuatNdrUABVaDEcibNkpKx7fYQk7nS6tIXQ0AAH2CYIhzM4MP9U1mRrEJoU5stMD5AqZUJZm3DigtVolizxYGMKI4KMgaFosD1HEgWFAAAM8Fay6Bs0JSFZlvAhIQADSMfDwnDoFXqijiDTQSTw3jCKwlujZlIWU48WDCELk1aVkg29Z24KF-Xj23ezeocdi3H4gBCZoA4qAOmZqcYOqAABIAUWpj7JGdAWcQDaH8NA6EgIjQAA5GIADuxJkviuQznAFClnuoBAZ4QH1qA0CQGISrCIgnCDmciKqhI0hyBGtDjghQF4NQWBkBgQEhD4HwAMxvAArLE77GEWqEVlGgTBBEDxBFRqA0bw6CBvGnBlouYjLtAMYMnGwqAvJabvseSoYBQ5C9uIQjIMQOBWPQkAMog4htjAHDgfSmComQ2gTpImGgIq8K-qBiCoik5C2OI8L8N55YiWJGDVrZ8KYOBcotu+Zw4GIDlOPCwgMP+IhoRhoAxdoQTvtB8iweR3FIaFtHoB4KFfllmGjjheEEfQREyPIihkfBpXleJ9GMSx7GyaA8mKbAj42AFQWwBa1EVcpKqbGp3UYLiyhAA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
// Contrived function in order to introduce generic rest parameters
function makeFn<TArgs extends any[]>(fn: (...args: TArgs) => any): (...args: TArgs) => string {
    return (...args) => JSON.stringify(fn(...args));
}

// Setup:
const foo = makeFn((a?: number) => (a ?? 0) + 42);
const bar = makeFn((b?: string) => (b?.length ?? 0) + 42);

// Works: calling functions individually with no args
const fooResult: string = foo();
const barResult: string = bar(); 

// Works: casting union to the concrete types and invoking with no args:
const concreteUnion = foo as (((a?: number) => string) | ((b?: string) => string));
const concreteUnionResult: string = concreteUnion();


// The hover type of `union` here is correct, including the optionalness of the arguments.
const union = foo as (typeof foo | typeof bar);

// BUG STARTS HERE:

// This call doesn't work:
// Argument of type '[]' is not assignable to parameter of type 'undefined'.(2345)
// Type is `union: (arg0: undefined) => string` - the "optionalness" of the arg has been lost.
const unionResult: string = union();

// Based on the previous tooltip, one would think that a call with an explicit `undefined` would work,
// but this also does not work: 
// Argument of type '[undefined]' is not assignable to parameter of type 'undefined'.(2345)
const unionResultExplicitUndefined: string = union(undefined);
```

### 🙁 Actual behavior

Invoking a union of functions (all with optional rest parameters) without any arguments raises a type error.

### 🙂 Expected behavior

No type error is raised in this scenario.