Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 1.12 KB

File metadata and controls

93 lines (66 loc) · 1.12 KB

typelab / utils / FunctionCallbackify

type FunctionCallbackify<T, ErrorType> = (...param) => void;

Converts an Async Function type into a Callback-style Function.

Type Parameters

Type Parameter Default type Description

T extends Fn<Any, Promise<Any>>

The Function type that returns a Promise.

ErrorType

unknown

Parameters

Parameter Type

...param

[...ExtractParams<T>, (error, result) => void]

Returns

void

A new Function type that accepts a callback for error handling and result.

Example

// (a: string, callback: (error: unknown, result: string) => void) => void
type Callbackified = FunctionCallbackify<(a: string) => Promise<string>>;