From 11f556cc22a8283ac649b2965b0472fecb8d413e Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Sun, 30 Nov 2014 16:36:16 +1300 Subject: [PATCH] Add overloads for when's members --- when/when.d.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/when/when.d.ts b/when/when.d.ts index c90478c10..62d2cfa0d 100644 --- a/when/when.d.ts +++ b/when/when.d.ts @@ -12,6 +12,33 @@ declare function When(value: When.Thenable, transform: (val: T) => U): declare function When(value: T, transform: (val: T) => U): When.Promise; declare module When { + function attempt(f: () => T): Promise; + + function attempt(f: (a: A) => T, a: Promise): Promise; + function attempt(f: (a: A) => T, a: A): Promise; + + function attempt(f: (a: A, b: B) => T, a: Promise, b: Promise): Promise; + function attempt(f: (a: A, b: B) => T, a: Promise, b: B): Promise; + function attempt(f: (a: A, b: B) => T, a: A, b: Promise): Promise; + function attempt(f: (a: A, b: B) => T, a: A, b: B): Promise; + + function attempt(f: (a: A, b: B, c: C) => T, a: Promise, b: Promise, c: Promise): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: Promise, b: Promise, c: C): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: Promise, b: B, c: Promise): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: Promise, b: B, c: C): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: A, b: Promise, c: Promise): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: A, b: Promise, c: C): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: A, b: B, c: Promise): Promise; + function attempt(f: (a: A, b: B, c: C) => T, a: A, b: B, c: C): Promise; + + function lift(f: () => T): () => Promise; + function lift(f: (a: A) => T): (a: Promise) => Promise; + function lift(f: (a: A, b: B) => T): (a: Promise, b: Promise) => Promise; + function lift(f: (a: A, b: B, c: C) => T): (a: Promise, b: Promise, c: Promise) => Promise; + + function promise(resolver: (resolve: (value: T) => void, reject: (reason: any) => void) => void): Promise; + + function reject(reason: any): Promise; /** * Return a promise that will resolve only once all the supplied promisesOrValues @@ -53,6 +80,7 @@ declare module When { * - rejected with promiseOrValue's reason after it is rejected */ function resolve(promise: Promise): Promise; + function resolve(foreign: Thenable): Promise; function resolve(value?: T): Promise; interface Deferred {