Closed
Description
openedon Oct 18, 2018
TypeScript Version: 3.2.0-dev.20181018
Search Terms:
Code
declare function f<T>(cf: (() => T) | ((x: T) => boolean)): void;
declare function myFn(): Date;
declare function myFn(n: number): void;
f<Date>(myFn); // works
f(myFn); // error
Expected behavior:
No error, as in typescript@3.1
.
Actual behavior:
src/a.ts:7:3 - error TS2345: Argument of type '{ (): Date; (n: number): void; }' is not assignable to parameter of type '(() => number) | ((x: number) => boolean)'.
Type '{ (): Date; (n: number): void; }' is not assignable to type '() => number'.
Type 'Date' is not assignable to type 'number'.
7 f(myFn); // error
Looks like this was introduced by #27028. Discovered in bluebird
on DefinitelyTyped -- in that case it had to do with type CatchFilter<E> = (new (...args: any[]) => E) | ((error: E) => boolean) | (object & E);
which unions a construct and call signature which more clearly should be separate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment