From d2b389f7dfb45dfce802719df2b06d8a9a06df20 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Tue, 23 Dec 2014 14:59:10 -0500 Subject: [PATCH] Fix type of ElementFinder's IThenable interface There are 2 edits here: 1. Remove unnecessarily overridden methods in ElementFinder (they are defined in IThenable). 2. Change the parameterized type in IThenable to 'any' to account for things like ElementFinder.evaluate() which may return primitive values. --- angular-protractor/angular-protractor.d.ts | 99 +--------------------- 1 file changed, 1 insertion(+), 98 deletions(-) diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index 8e24c5f572..002676c25f 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -534,7 +534,7 @@ declare module protractor { all(locator: webdriver.Locator): ElementArrayFinder; } - interface ElementFinder extends webdriver.IWebElement, webdriver.promise.IThenable { + interface ElementFinder extends webdriver.IWebElement, webdriver.promise.IThenable { /** * Calls to element may be chained to find elements within a parent. * @@ -701,103 +701,6 @@ declare module protractor { */ allowAnimations(value: string): ElementFinder; - /** - * Cancels the computation of this promise's value, rejecting the promise in the - * process. This method is a no-op if the promise has alreayd been resolved. - * - * @param {string=} opt_reason The reason this promise is being cancelled. - */ - cancel(opt_reason?: string): void; - - - /** @return {boolean} Whether this promise's value is still being computed. */ - isPending(): boolean; - - - /** - * Registers listeners for when this instance is resolved. - * - * @param {?(function(T): (R|webdriver.promise.Promise.))=} opt_callback The - * function to call if this promise is successfully resolved. The function - * should expect a single argument: the promise's resolved value. - * @param {?(function(*): (R|webdriver.promise.Promise.))=} opt_errback The - * function to call if this promise is rejected. The function should expect - * a single argument: the rejection reason. - * @return {!webdriver.promise.Promise.} A new promise which will be - * resolved with the result of the invoked callback. - * @template R - */ - then(opt_callback?: (value: ElementFinder) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise; - - - /** - * Registers a listener for when this promise is rejected. This is synonymous - * with the {@code catch} clause in a synchronous API: - *

-         *   // Synchronous API:
-         *   try {
-         *     doSynchronousWork();
-         *   } catch (ex) {
-         *     console.error(ex);
-         *   }
-         *
-         *   // Asynchronous promise API:
-         *   doAsynchronousWork().thenCatch(function(ex) {
-         *     console.error(ex);
-         *   });
-         * 
- * - * @param {function(*): (R|webdriver.promise.Promise.)} errback The function - * to call if this promise is rejected. The function should expect a single - * argument: the rejection reason. - * @return {!webdriver.promise.Promise.} A new promise which will be - * resolved with the result of the invoked callback. - * @template R - */ - thenCatch(errback: (error: any) => any): webdriver.promise.Promise; - - - /** - * Registers a listener to invoke when this promise is resolved, regardless - * of whether the promise's value was successfully computed. This function - * is synonymous with the {@code finally} clause in a synchronous API: - *

-         *   // Synchronous API:
-         *   try {
-         *     doSynchronousWork();
-         *   } finally {
-         *     cleanUp();
-         *   }
-         *
-         *   // Asynchronous promise API:
-         *   doAsynchronousWork().thenFinally(cleanUp);
-         * 
- * - * Note: similar to the {@code finally} clause, if the registered - * callback returns a rejected promise or throws an error, it will silently - * replace the rejection error (if any) from this promise: - *

-         *   try {
-         *     throw Error('one');
-         *   } finally {
-         *     throw Error('two');  // Hides Error: one
-         *   }
-         *
-         *   webdriver.promise.rejected(Error('one'))
-         *       .thenFinally(function() {
-         *         throw Error('two');  // Hides Error: one
-         *       });
-         * 
- * - * - * @param {function(): (R|webdriver.promise.Promise.)} callback The function - * to call when this promise is resolved. - * @return {!webdriver.promise.Promise.} A promise that will be fulfilled - * with the callback result. - * @template R - */ - thenFinally(callback: () => any): webdriver.promise.Promise; - /** * Create a shallow copy of ElementFinder. *