selenium-webdriver: Enable strictNullChecks and fix (#19749)

This commit is contained in:
Andy
2017-09-15 07:12:16 -07:00
committed by GitHub
parent 2673835592
commit d9a565f48c
4 changed files with 23 additions and 151 deletions
+6 -140
View File
@@ -862,49 +862,8 @@ export namespace promise {
* @interface
* @template T
*/
class Thenable<T> implements IThenable<T> {
/**
* Registers listeners for when this instance is resolved.
*
* @param onfulfilled
* The function to call if this promise is successfully resolved. The function
* should expect a single argument: the promise's resolved value.
* @param onrejected
* The function to call if this promise is rejected. The function should
* expect a single argument: the rejection reason.
* @return A new promise which will be resolved with the result
* of the invoked callback.
* @template R
*/
then<TResult1 = T, TResult2 = never>(
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
/**
* 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().catch(function(ex) {
* console.error(ex);
* });
*
* @param {function(*): (R|IThenable<R>)} errback The
* function to call if this promise is rejected. The function should
* expect a single argument: the rejection reason.
* @return {!ManagedPromise<R>} A new promise which will be
* resolved with the result of the invoked callback.
* @template R
*/
catch<R>(errback: Function): Promise<R>;
interface Thenable<T> extends IThenable<T> {}
class Thenable<T> {
/**
* Registers a listener to invoke when this promise is resolved, regardless
* of whether the promise's value was successfully computed. This function
@@ -2025,7 +1984,8 @@ export class Alert {
* @implements {promise.Thenable.<!Alert>}
* @final
*/
export class AlertPromise extends Alert implements promise.IThenable<Alert> {
export interface AlertPromise extends promise.IThenable<Alert> {}
export class AlertPromise extends Alert {
/**
* @param {!WebDriver} driver The driver controlling the browser this
* alert is attached to.
@@ -2033,48 +1993,6 @@ export class AlertPromise extends Alert implements promise.IThenable<Alert> {
* that will be fulfilled with the promised alert.
*/
constructor(driver: WebDriver, alert: promise.Promise<Alert>);
// region Methods
/**
* Registers listeners for when this instance is resolved. This function most
* overridden by subtypes.
*
* @param 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 opt_errback The function to call if this promise is
* rejected. The function should expect a single argument: the rejection
* reason.
* @return A new promise which will be resolved
* with the result of the invoked callback.
*/
then(opt_callback?: Function, opt_errback?: Function): promise.Promise<any>;
/**
* 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().catch(function(ex) {
* console.error(ex);
* });
*
* @param {function(*): (R|IThenable<R>)} errback The
* function to call if this promise is rejected. The function should
* expect a single argument: the rejection reason.
* @return {!ManagedPromise<R>} A new promise which will be
* resolved with the result of the invoked callback.
* @template R
*/
catch<R>(errback: Function): promise.Promise<R>;
}
/**
@@ -4776,7 +4694,8 @@ export class WebElement implements Serializable<IWebElementId> {
* @implements {promise.Thenable.<!WebElement>}
* @final
*/
export class WebElementPromise extends WebElement implements promise.IThenable<WebElement> {
export interface WebElementPromise extends promise.IThenable<WebElement> {}
export class WebElementPromise extends WebElement {
/**
* @param {!WebDriver} driver The parent WebDriver instance for this
* element.
@@ -4784,59 +4703,6 @@ export class WebElementPromise extends WebElement implements promise.IThenable<W
* that will resolve to the promised element.
*/
constructor(driver: WebDriver, el: promise.Promise<WebElement>);
/**
* Registers listeners for when this instance is resolved.
*
* @param 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 opt_errback The
* function to call if this promise is rejected. The function should expect
* a single argument: the rejection reason.
* @return A new promise which will be
* resolved with the result of the invoked callback.
*/
then<R>(opt_callback?: (value: WebElement) => promise.Promise<R>, opt_errback?: (error: any) => any): promise.Promise<R>;
/**
* Registers listeners for when this instance is resolved.
*
* @param 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 opt_errback The
* function to call if this promise is rejected. The function should expect
* a single argument: the rejection reason.
* @return A new promise which will be
* resolved with the result of the invoked callback.
*/
then<R>(opt_callback?: (value: WebElement) => R, opt_errback?: (error: any) => any): promise.Promise<R>;
/**
* 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().catch(function(ex) {
* console.error(ex);
* });
*
* @param {function(*): (R|IThenable<R>)} errback The
* function to call if this promise is rejected. The function should
* expect a single argument: the rejection reason.
* @return {!ManagedPromise<R>} A new promise which will be
* resolved with the result of the invoked callback.
* @template R
*/
catch<R>(errback: Function): promise.Promise<R>;
}
/**
+14 -10
View File
@@ -30,6 +30,8 @@ function TestBuilder() {
builder = builder.withCapabilities({ something: true });
}
declare const promise: webdriver.promise.Promise<string>;
function TestActionSequence() {
let driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
@@ -37,7 +39,6 @@ function TestActionSequence() {
let sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver);
let element: webdriver.WebElement = new webdriver.WebElement(driver, 'elementId');
let promise: webdriver.promise.Promise<string>;
element = new webdriver.WebElement(driver, promise);
// Click
@@ -519,7 +520,7 @@ function TestWebDriverOptions() {
promise = options.deleteAllCookies();
promise = options.deleteCookie('name');
options.getCookie('name').then((cookie: webdriver.IWebDriverCookie) => {
let expiry: number = cookie.expiry;
let expiry: number | undefined = cookie.expiry;
});
options.getCookies().then((cookies: webdriver.IWebDriverCookie[]) => { });
@@ -573,9 +574,13 @@ function TestWebDriverWindow() {
voidPromise = window.setSize(12, 34);
}
declare const sessionPromise: webdriver.promise.Promise<webdriver.Session>;
declare let booleanPromise: webdriver.promise.Promise<boolean>;
declare const booleanCondition: webdriver.Condition<boolean>;
declare const webElementCondition: webdriver.WebElementCondition;
function TestWebDriver() {
let session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
let sessionPromise: webdriver.promise.Promise<webdriver.Session>;
let httpClient: http.HttpClient = new http.HttpClient('http://someserver');
let executor: http.Executor = new http.Executor(httpClient);
let flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
@@ -586,7 +591,6 @@ function TestWebDriver() {
let voidPromise: webdriver.promise.Promise<void>;
let stringPromise: webdriver.promise.Promise<string>;
let booleanPromise: webdriver.promise.Promise<boolean>;
let webElementPromise: webdriver.WebElementPromise;
let actions: webdriver.ActionSequence = driver.actions();
@@ -643,7 +647,6 @@ function TestWebDriver() {
voidPromise = driver.sleep(123);
stringPromise = driver.takeScreenshot();
let booleanCondition: webdriver.Condition<boolean>;
booleanPromise = driver.wait(booleanPromise);
booleanPromise = driver.wait(booleanCondition);
booleanPromise = driver.wait((driver: webdriver.WebDriver) => true);
@@ -651,7 +654,6 @@ function TestWebDriver() {
booleanPromise = driver.wait((driver: webdriver.WebDriver) => webdriver.promise.Promise.resolve(true));
booleanPromise = driver.wait(booleanPromise, 123);
booleanPromise = driver.wait(booleanPromise, 123, 'Message');
let webElementCondition: webdriver.WebElementCondition;
webElementPromise = driver.wait(webElementCondition);
voidPromise = driver.wait(webElementCondition).click();
@@ -659,8 +661,9 @@ function TestWebDriver() {
driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android());
}
declare const serializable: webdriver.Serializable<string>;
function TestSerializable() {
let serializable: webdriver.Serializable<string>;
let serial: string | webdriver.promise.IThenable<string> = serializable.serialize();
}
@@ -669,7 +672,6 @@ function TestWebElement() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
let promise: webdriver.promise.Promise<string>;
let element: webdriver.WebElement;
element = new webdriver.WebElement(driver, 'elementId');
@@ -764,13 +766,14 @@ function TestLoggingEntry() {
let type: string = entry.type;
}
declare let stringPromise: webdriver.promise.Promise<string>;
function TestPromiseModule() {
let cancellationError: webdriver.promise.CancellationError = new webdriver.promise.CancellationError();
cancellationError = new webdriver.promise.CancellationError('message');
let str: string = cancellationError.message;
str = cancellationError.name;
let stringPromise: webdriver.promise.Promise<string>;
let numberPromise: webdriver.promise.Promise<number>;
let booleanPromise: webdriver.promise.Promise<boolean>;
let voidPromise: webdriver.promise.Promise<void>;
@@ -932,8 +935,9 @@ function TestDeferred() {
deferred.removeAll();
}
declare const controlFlow: webdriver.promise.ControlFlow;
function TestPromiseClass() {
let controlFlow: webdriver.promise.ControlFlow;
let promise: webdriver.promise.Promise<string>;
promise = new webdriver.promise.Promise<string>((resolve, reject) => {
resolve("");
+1 -1
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+2
View File
@@ -9,6 +9,8 @@
"jsdoc-format": false,
"no-empty-interface": false,
"no-inferrable-types": false,
"no-any-union": false,
"no-unnecessary-generics": false,
"prefer-const": false,
"semicolon": false,
"unified-signatures": false