🔎 Search Terms
call union expected arguments but got
🕗 Version & Regression Information
Before version 4.5 both the .calls in the example below failed. Since then, .call(null, something-not-any) is accepted and .call(null, something-any) failes.
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.5.0-beta#code/CYUwxgNghgTiAEYD2A7AzgF3gMxQLngApCBKeAXgD54A3JAS2DIB8jCoCUBXAWwCMQMMlVoMmAKHGhIsBMnRYAHp14CYAbinhocRKkzwAngSgpDm8bgB0YKBAiFu9gDTxFJTddv3HXF0Y9JXEJDQOD3CyA
💻 Code
declare const fn: (() => void) | ((a: number) => void)
declare const x: number;
declare const y: any;
fn.call(null, x); // ok
fn.call(null, y); // error
fn(y); // ok
fn(x); // ok
🙁 Actual behavior
The line marked as // error gives the following error:
Expected 1 arguments, but got 2.
🙂 Expected behavior
It should be accepted, the same as the other lines are accepted.
Additional information about the issue
No response
TODO for myself: Remove @ts-ignore in https://github.com/babel/babel/blob/main/packages/babel-generator/src/printer.ts#L717 once this is fixed