declare namespace dojo { namespace promise { /* dojo/promise/all */ type PromiseObjectOrArray = { [name: string]: Promise } | Promise[]; type PromiseTypedObjectOrArray = { [name: string]: Promise } | Promise[]; interface All { /** * Takes multiple promises and returns a new promise that is fulfilled * when all promises have been resolved or one has been rejected. * @param objectOrArray The promise will be fulfilled with a list of results if invoked with an * array, or an object of results when passed an object (using the same * keys). If passed neither an object or array it is resolved with an * undefined value. */ (array: Thenable[]): Promise; (object: { [name: string]: Thenable }): Promise<{ [name: string]: T }>; (array: Thenable[]): Promise; (object: { [name: string]: Thenable }): Promise<{ [name: string]: any }>; } /* dojo/promise/first */ interface First { /** * Takes multiple promises and returns a new promise that is fulfilled * when the first of these promises is fulfilled. * @param objectOrArray The promises are taken from the array or object values. If no value * is passed, the returned promise is resolved with an undefined value. */ (objectOrArray?: PromiseTypedObjectOrArray): Promise; (objectOrArray?: PromiseObjectOrArray): Promise; } /* dojo/promise/instrumentation */ interface Instrumentation { /** * Initialize instrumentation for the Deferred class. */ (Deferred: DeferredConstructor): void; } /* dojo/promise/Promise */ type Thenable = PromiseLike; interface PromiseCallback { (result: T): U | Thenable; } interface PromiseErrback { (error: any): U | Thenable | void; } interface PromiseProgback { (progress: any): void; } interface Promise extends Thenable { /** * Inform the deferred it may cancel its asynchronous operation. */ cancel(reason?: any, strict?: boolean): any; /** * Checks whether the promise has been resolved. */ isResolved(): boolean; /** * Checks whether the promise has been rejected. */ isRejected(): boolean; /** * Checks whether the promise has been resolved or rejected. */ isFulfilled(): boolean; /** * Checks whether the promise has been canceled. */ isCanceled(): boolean; /** * Add a callback to be invoked when the promise is resolved * or rejected. */ always(callbackOrErrback: PromiseCallback | PromiseErrback): Promise; /** * Add new errbacks to the promise. Follows ECMA specification naming. */ catch(errback: PromiseErrback): Promise; /** * Add new errbacks to the promise. */ otherwise(errback: PromiseErrback): Promise; trace(): this; traceRejected(): this; toString(): string; } interface PromiseConstructor { /** * The public interface to a deferred. */ new (): Promise; } /* dojo/promise/tracer */ /* TODO: Uncomment for TS 1.8 */ /* type TracerEvent = 'resolved' | 'rejected' | 'progress'; */ interface Tracer { /** * Subscribe to traces. */ on(type: string /* TracerEvent */, listener: EventListener): Handle; } } }