export interface Deferred < T = void > extends Promise < T > { resolve : ( result ? : T | PromiseLike < T > ) => void ; reject : ( error : Error ) => void ; } export default function defer < T = void > ( ) { let resolve ; let reject ; return Object . assign ( new Promise < T > ( ( _resolve , _reject ) => { resolve = _resolve ; reject = _reject ; } ) , { resolve , reject } ) ; }