export interface ExposedPromise < T > { promise : Promise < T > ; resolve ( value ? ) : void ; reject ( reason ? ) : void ; } function notInitialized ( ) { throw new Error ( 'ExposedPromise not initialized yet.' ) ; } export function exposedPromise < T > ( ) { let resolve = notInitialized ; let reject = notInitialized ; const promise = new Promise < T > ( ( innerResolve , innerReject ) => { resolve = innerResolve ; reject = innerReject ; } ) ; return { promise , resolve , reject } ; }