DefinitelyTyped/types/promise.allsettled/types.d.ts
Martin Jurča 57356feb55 [promise.allsettled] Fix type declarations for non-tuple inputs (#36815)
* added type definitions for promise.allsettled

* code style update

* code style and compatibility fixes

* removed the (hopefully not needed) tslint disable flag

* more code style fixes

* code style fix

* fixed the result type for iterable non-tuple inputs, made the types more practical

* fixed code style
2019-07-11 15:54:03 -07:00

15 lines
454 B
TypeScript

export interface PromiseResolution<T> {
status: 'fulfilled';
value: T;
}
export interface PromiseRejection<E> {
status: 'rejected';
reason: E;
}
export type PromiseResult<T, E = unknown> = PromiseResolution<T> | PromiseRejection<E>;
export type PromiseTuple<T extends [unknown, ...unknown[]]> = {[P in keyof T]: Promise<T[P]>};
export type PromiseResultTuple<T extends [unknown, ...unknown[]]> = {[P in keyof T]: PromiseResult<T[P]>};