The DeferredPromise type is used to describe a promise that can be resolved or rejected after it has been created.
type DeferredPromise<T> = Promise<T> & {
__deferredState: DeferredPromiseState<T>
}
type DeferredPromiseState<T> = { uid: string } & (
| {
status: 'pending'
data?: T
error?: unknown
}
| {
status: 'success'
data: T
}
| {
status: 'error'
data?: T
error: unknown
}
)
type DeferredPromise<T> = Promise<T> & {
__deferredState: DeferredPromiseState<T>
}
type DeferredPromiseState<T> = { uid: string } & (
| {
status: 'pending'
data?: T
error?: unknown
}
| {
status: 'success'
data: T
}
| {
status: 'error'
data?: T
error: unknown
}
)
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.