diff --git a/lib/utils.ts b/lib/utils.ts index 297576ef..7c088ee8 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,11 +1,8 @@ -/** A callback function that expects an error to be passed. */ -export type ErrorCallback = (error: Error, result?: never) => void - -/** A callback function that expects a successful result. */ -type SuccessCallback = (error: null, result: T) => void - /** A callback function that accepts an error or a result. */ -export type Callback = SuccessCallback & ErrorCallback +export interface Callback { + (error: Error, result?: never): void + (error: null, result: T): void +} /** Safely converts any value to string, using the value's own `toString` when available. */ export const safeToString = (val: unknown) => { diff --git a/lib/validators.ts b/lib/validators.ts index cfc4d500..a705d162 100644 --- a/lib/validators.ts +++ b/lib/validators.ts @@ -26,7 +26,7 @@ SOFTWARE. ************************************************************************************ */ -import { ErrorCallback, safeToString } from './utils' +import { Callback, safeToString } from './utils' /* Validation functions copied from check-types package - https://www.npmjs.com/package/check-types */ @@ -68,7 +68,7 @@ export function isInteger(data: unknown): boolean { */ export function validate( bool: boolean, - cbOrMessage?: ErrorCallback | string, + cbOrMessage?: Callback | string, message?: string, ): void { if (bool) return // Validation passes