-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Copy link
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
🔎 Search Terms
call union expected arguments but got
🕗 Version & Regression Information
Before version 4.5 both the .call
s in the example below failed. Since then, .call(null, something-not-any)
is accepted and .call(null, something-any)
failes.
⏯ Playground Link
💻 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
Metadata
Metadata
Assignees
Labels
Help WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases