Closed as not planned
Closed as not planned
Description
π Search Terms
"overload", "last overload", "is not assignable to parameter of type", "Array.map"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
π» Code
declare function foo(value: string): string;
declare function foo(value: number): number;
const r0: string[] = ["a", "b"].map(_ => foo(_)); // ok
const r1: string[] = ["a", "b"].map(foo); // error, number is inferred
π Actual behavior
It looks like when foo
is passed "directly" (that is without a wrapper arrow function), its signature is the last one that was declared. Swapping the first two lines works around the issue, indeed.
π Expected behavior
It should iterate through all the possible overloads.
Additional information about the issue
No response