From 1221ff85a08a1072ce8d6ffc8758294fb952bed8 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Thu, 13 Sep 2018 16:51:00 -0700 Subject: [PATCH] Add PromiseLike-compatible type for then (#28866) --- types/q/index.d.ts | 2 +- types/q/q-tests.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/q/index.d.ts b/types/q/index.d.ts index bdcd3c68ca..7926965cf8 100644 --- a/types/q/index.d.ts +++ b/types/q/index.d.ts @@ -61,7 +61,7 @@ declare namespace Q { * The then method from the Promises/A+ specification, with an additional progress handler. */ then(onFulfill?: ((value: T) => IWhenable) | null, onReject?: ((error: any) => IWhenable) | null, onProgress?: ((progress: any) => any) | null): Promise; - + then(onFulfill?: ((value: T) => IWhenable) | null, onReject?: ((error: any) => IWhenable) | null, onProgress?: ((progress: any) => any) | null): Promise; /** * 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, diff --git a/types/q/q-tests.ts b/types/q/q-tests.ts index 226d86ced8..62160614e4 100644 --- a/types/q/q-tests.ts +++ b/types/q/q-tests.ts @@ -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 = Q.Promise((resolve) => resolve()); + // thenReject, returning a Promise of the same type as the Promise it is called on function thenRejectSameType(arg: any): Q.Promise { if (!arg) {