Alexander Mills
Alexander Mills

Reputation: 100190

import resolve and reject function types from TypeScript definitions

I have a function, and I pass resolve and reject to it:

resolve: Function, reject: Function

aka:

new Promise((resolve, reject) => {
   helper(resolve,reject);
})

I am looking for the type definitions for these two functions (I know they are simple, but I might as well use the official ones).

I see this question/answers: How to use Typescript with native ES6 Promises

but unfortunately, none of them mention the actual definition to use, anyone know?

Upvotes: 1

Views: 781

Answers (1)

amiramw
amiramw

Reputation: 506

The definition of promise constructor is:

declare type PromiseConstructorLike = 
    new <T>(executor: 
        (resolve: (value?: T | PromiseLike<T>) => void, 
         reject: (reason?: any) => void) => void) => PromiseLike<T>;

You can copy the same.

Upvotes: 1

Related Questions