mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-14 22:40:03 +08:00
Add PromiseLike-compatible type for then (#28866)
This commit is contained in:
2
types/q/index.d.ts
vendored
2
types/q/index.d.ts
vendored
@@ -61,7 +61,7 @@ declare namespace Q {
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill?: ((value: T) => IWhenable<U>) | null, onReject?: ((error: any) => IWhenable<U>) | null, onProgress?: ((progress: any) => any) | null): Promise<U>;
|
||||
|
||||
then<U = T, V = never>(onFulfill?: ((value: T) => IWhenable<U>) | null, onReject?: ((error: any) => IWhenable<V>) | null, onProgress?: ((progress: any) => any) | null): Promise<U | V>;
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so
|
||||
* without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded,
|
||||
|
||||
@@ -245,6 +245,9 @@ Q.try(() => {
|
||||
})
|
||||
.catch((error) => console.error("Couldn't sync to the cloud", error));
|
||||
|
||||
// ensure Q.Promise is compatible with PromiseLike
|
||||
const p7: PromiseLike<void> = Q.Promise<void>((resolve) => resolve());
|
||||
|
||||
// thenReject, returning a Promise of the same type as the Promise it is called on
|
||||
function thenRejectSameType(arg: any): Q.Promise<number> {
|
||||
if (!arg) {
|
||||
|
||||
Reference in New Issue
Block a user