summaryrefslogtreecommitdiff
path: root/std/node/_util/_util_promisify_test.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-08-25 09:43:54 +1000
committerGitHub <noreply@github.com>2020-08-24 19:43:54 -0400
commitc4d5b01acfe0cac31f94743a57e8e619178ba563 (patch)
tree1987fe2e23c4db59a44159f4c7d21ecc61be4ad3 /std/node/_util/_util_promisify_test.ts
parent9b0f9c876529696c8008dda8b3606e34d3fe98dc (diff)
feat: update to TypeScript 4.0 (#6514)
Diffstat (limited to 'std/node/_util/_util_promisify_test.ts')
-rw-r--r--std/node/_util/_util_promisify_test.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/std/node/_util/_util_promisify_test.ts b/std/node/_util/_util_promisify_test.ts
index 67ca6af58..6271a8581 100644
--- a/std/node/_util/_util_promisify_test.ts
+++ b/std/node/_util/_util_promisify_test.ts
@@ -29,6 +29,9 @@ import {
import { promisify } from "./_util_promisify.ts";
import * as fs from "../fs.ts";
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type VoidFunction = (...args: any[]) => void;
+
const readFile = promisify(fs.readFile);
const customPromisifyArgs = Symbol.for("nodejs.util.promisify.customArgs");
@@ -87,7 +90,7 @@ Deno.test("Custom promisify args", async function testPromisifyCustomArgs() {
const firstValue = 5;
const secondValue = 17;
- function fn(callback: Function): void {
+ function fn(callback: VoidFunction): void {
callback(null, firstValue, secondValue);
}
@@ -101,7 +104,7 @@ Deno.test("Custom promisify args", async function testPromisifyCustomArgs() {
Deno.test(
"Multiple callback args without custom promisify args",
async function testPromisifyWithoutCustomArgs() {
- function fn(callback: Function): void {
+ function fn(callback: VoidFunction): void {
callback(null, "foo", "bar");
}
const value = await promisify(fn)();
@@ -112,7 +115,7 @@ Deno.test(
Deno.test(
"Undefined resolved value",
async function testPromisifyWithUndefinedResolvedValue() {
- function fn(callback: Function): void {
+ function fn(callback: VoidFunction): void {
callback(null);
}
const value = await promisify(fn)();
@@ -123,7 +126,7 @@ Deno.test(
Deno.test(
"Undefined resolved value II",
async function testPromisifyWithUndefinedResolvedValueII() {
- function fn(callback: Function): void {
+ function fn(callback: VoidFunction): void {
callback();
}
const value = await promisify(fn)();
@@ -134,7 +137,7 @@ Deno.test(
Deno.test(
"Resolved value: number",
async function testPromisifyWithNumberResolvedValue() {
- function fn(err: Error | null, val: number, callback: Function): void {
+ function fn(err: Error | null, val: number, callback: VoidFunction): void {
callback(err, val);
}
const value = await promisify(fn)(null, 42);
@@ -145,7 +148,7 @@ Deno.test(
Deno.test(
"Rejected value",
async function testPromisifyWithNumberRejectedValue() {
- function fn(err: Error | null, val: null, callback: Function): void {
+ function fn(err: Error | null, val: null, callback: VoidFunction): void {
callback(err, val);
}
await assertThrowsAsync(
@@ -157,9 +160,8 @@ Deno.test(
);
Deno.test("Rejected value", async function testPromisifyWithAsObjectMethod() {
- const o: { fn?: Function } = {};
- const fn = promisify(function (cb: Function): void {
- // @ts-expect-error TypeScript
+ const o: { fn?: VoidFunction } = {};
+ const fn = promisify(function (this: unknown, cb: VoidFunction): void {
cb(null, this === o);
});
@@ -177,7 +179,7 @@ Deno.test(
);
const stack = err.stack;
- const fn = promisify(function (cb: Function): void {
+ const fn = promisify(function (cb: VoidFunction): void {
cb(null);
cb(err);
});
@@ -203,7 +205,7 @@ Deno.test("Test error", async function testInvalidArguments() {
a: number,
b: number,
c: number,
- cb: Function,
+ cb: VoidFunction,
): void {
errToThrow = new Error(`${a}-${b}-${c}-${cb}`);
throw errToThrow;