type ResolveFn = (result: T | PromiseLike) => void; type RejectFn = (error: Error) => void; export interface IDeferredPromise { promise: Promise; resolve: ResolveFn; reject: RejectFn; } export function createDeferredPromise(): IDeferredPromise { const deferred: Partial> = {}; deferred.promise = new Promise((resolve, reject) => { deferred.resolve = resolve; deferred.reject = reject; }); return deferred as IDeferredPromise; }