🔎 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
https://www.typescriptlang.org/play?ts=5.3.0-dev.20230923&ssl=2&ssc=1&pln=3&pc=1#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVJxwAoA3KCZEALngGcMYtUBzAShvsZYG4BYAKFCRYCFOmx4CxMhWrxUyALYAjEDHbylqmH34CweevBgAGDgybMA2gF14AXnhWARFGcAaeM+XObAOkUoAAciAH0HAD4pMNZWbngAegT4HABrfUMMYwBGcy5rO0cXN09vXwDgokRCOMTktRgcGAEgA
💻 Code
declarefunctionfoo(value: string): string;declarefunctionfoo(value: number): number;constr0: string[]=["a","b"].map(_=>foo(_));// okconstr1: 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
🔎 Search Terms
"overload", "last overload", "is not assignable to parameter of type", "Array.map"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.3.0-dev.20230923&ssl=2&ssc=1&pln=3&pc=1#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVJxwAoA3KCZEALngGcMYtUBzAShvsZYG4BYAKFCRYCFOmx4CxMhWrxUyALYAjEDHbylqmH34CweevBgAGDgybMA2gF14AXnhWARFGcAaeM+XObAOkUoAAciAH0HAD4pMNZWbngAegT4HABrfUMMYwBGcy5rO0cXN09vXwDgokRCOMTktRgcGAEgA
💻 Code
🙁 Actual behavior
It looks like when
foois 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