Closed
Description
TypeScript Version: 3.6.0-dev.20190613
Search Terms:
overload
higher order function
checkjs
Code
// id.d.ts
declare type Unary = (a: number) => void;
declare type Binary = (a: number, b: number) => void;
export declare function id(fn: Unary): Unary;
export declare function id(fn: Binary): Binary;
export {};
// id.js
export const id = fn => fn;
// index.js
import {id} from './id'
// expected f: Binary
// actual f: Unary
const f = id((a, b) => {});
// Error: Expected 1 arguments, but got 2.
f(1, 2);
Expected behavior:
f is a binary function.
Actual behavior:
f is a unary function.
Playground Link:
N/A
Related Issues:
This issue makes util.promisify
in @types/node
unusable with checkjs. See
DefinitelyTyped/DefinitelyTyped#33340