A standard pattern for a resolvable, rejectable Promise, based on the emerging ES2023 standard. Type ported from https://github.com/microsoft/TypeScript/pull/56593

interface PromiseWithResolvers<T> {
    promise: Promise<T>;
    reject: ((reason?) => void);
    resolve: ((value) => void);
}

Type Parameters

  • T

Properties

promise: Promise<T>
reject: ((reason?) => void)

Type declaration

    • (reason?): void
    • Parameters

      • Optional reason: any

      Returns void

resolve: ((value) => void)

Type declaration

    • (value): void
    • Parameters

      • value: T | PromiseLike<T>

      Returns void