-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptExperimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensSuggestionAn idea for TypeScriptAn idea for TypeScript