Description
TypeScript Version: 3.8.0-dev.20191121
Search Terms:
callback overload mismatch
Code
declare function fn(x: string): string;
declare function fn(x: string[]): string;
declare function map<A, R>(fn: (item: A) => R, list: A[]): R[];
const mapped = map(fn, ['1']) // error
Expected behavior:
TypeScript does infer A
as string
and could choose the right overload fn(x: string)
, decline the ones that don't fit.
Actual behavior:
Checks the last overload only, so it shows an error.
Related Issues: