import e = require("../_base/lang"); class Promise implements DojoJS.Thenable { /** * Add new callbacks to the promise. */ then(callback?: ((result: T) => U | DojoJS.Thenable) | null, errback?: ((error: any) => U | DojoJS.Thenable | void) | null, progback?: ((progress: any) => void) | null): Promise { throw new TypeError("abstract"); } /** * Inform the deferred it may cancel its asynchronous operation. */ cancel(reason?: any, strict?: boolean): any { throw new TypeError("abstract"); } /** * Checks whether the promise has been resolved. */ isResolved(): boolean { throw new TypeError("abstract"); } /** * Checks whether the promise has been rejected. */ isRejected(): boolean { throw new TypeError("abstract"); } /** * Checks whether the promise has been resolved or rejected. */ isFulfilled(): boolean { throw new TypeError("abstract"); } /** * Checks whether the promise has been canceled. */ isCanceled(): boolean { throw new TypeError("abstract"); } /** * Add a callback to be invoked when the promise is resolved * or rejected. */ always(callbackOrErrback: (result: T) => U | DojoJS.Thenable | void): Promise { return this.then(callbackOrErrback, callbackOrErrback); } /** * Add new errbacks to the promise. Follows ECMA specification naming. */ catch(errback: (error: any) => U | DojoJS.Thenable): Promise { return this.then(null, errback); } /** * Add new errbacks to the promise. */ otherwise(errback: (error: any) => U | DojoJS.Thenable): Promise { return this.then(null, errback); } trace(): this { return this; } traceRejected(): this { return this; } toString(): string { return "[object Promise]"; } } declare global { namespace DojoJS { interface Thenable { /** * Add new callbacks to the promise. */ then(callback?: ((result: T) => U | Thenable) | null, errback?: ((error: any) => U | Thenable | void) | null, progback?: ((progress: any) => void) | null): Promise; } type Promise = InstanceType>; } } export = Promise;