export class Deferred { resolve?: (reason: T | PromiseLike) => void; reject?: (reason?: any) => void; promise: Promise; constructor() { this.resolve = undefined; this.reject = undefined; this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); Object.freeze(this); } }