Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sherman committed Dec 18, 2021
1 parent 5bbe811 commit ac254be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
19 changes: 6 additions & 13 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expectError, expectType } from "tsd";
import * as fs from "fs";
import pify = require(".");

expectError(pify());
Expand All @@ -14,10 +13,6 @@ expectError(pify("abc", {}));

expectType<never>(pify((v: number) => {})());

// basic
// It returns a Buffer because it chooses the last overload of the passed function
expectType<Promise<Buffer>>(pify(fs.readFile)("path"));

// callback with 0 additional params
declare function fn0(fn: (val: number) => void): void;
expectType<Promise<number>>(pify(fn0)());
Expand Down Expand Up @@ -92,12 +87,10 @@ expectType<Promise<[number, string]>>(
pify(callback22, { multiArgs: true })("a", "b")
);

expectType<Promise<[NodeJS.ErrnoException | null, Buffer]>>(
pify(fs.readFile, { multiArgs: true })("path")
);
expectType<Promise<Buffer>>(pify(fs.readFile, { multiArgs: false })("path"));

declare function foo(a: number, b: number): number;
declare function foo(a: string, b: string): string;
// overloads
declare function overloaded(value: number, cb: (value: number) => void): void;
declare function overloaded(value: string, cb: (value: string) => void): void;

type X = Parameters<typeof foo>;
// Chooses last overload
// See https://github.com/microsoft/TypeScript/issues/32164
expectType<Promise<string>>(pify(overloaded)(""));
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"bluebird"
],
"devDependencies": {
"@types/node": "^17.0.0",
"ava": "^2.4.0",
"pinkie-promise": "^2.0.0",
"tsd": "^0.19.0",
Expand Down

0 comments on commit ac254be

Please sign in to comment.