refactor(TypeScript): Add noImplicitAny
We automatically insert explicit 'any's where needed. These need to be addressed as in #9100. Fixes #4924
This commit is contained in:
@ -11,8 +11,8 @@ export function getIntParameter(name: string) {
|
||||
|
||||
export function getStringParameter(name: string) {
|
||||
var els = DOM.querySelectorAll(document, `input[name="${name}"]`);
|
||||
var value;
|
||||
var el;
|
||||
var value: any /** TODO #9100 */;
|
||||
var el: any /** TODO #9100 */;
|
||||
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
el = els[i];
|
||||
@ -32,10 +32,10 @@ export function getStringParameter(name: string) {
|
||||
|
||||
export function bindAction(selector: string, callback: Function) {
|
||||
var el = DOM.querySelector(document, selector);
|
||||
DOM.on(el, 'click', function(_) { callback(); });
|
||||
DOM.on(el, 'click', function(_: any /** TODO #9100 */) { callback(); });
|
||||
}
|
||||
|
||||
export function microBenchmark(name, iterationCount, callback) {
|
||||
export function microBenchmark(name: any /** TODO #9100 */, iterationCount: any /** TODO #9100 */, callback: any /** TODO #9100 */) {
|
||||
var durationName = `${name}/${iterationCount}`;
|
||||
window.console.time(durationName);
|
||||
callback();
|
||||
|
@ -52,7 +52,7 @@ export class BrowserDetection {
|
||||
|
||||
BrowserDetection.setup();
|
||||
|
||||
export function dispatchEvent(element, eventType): void {
|
||||
export function dispatchEvent(element: any /** TODO #9100 */, eventType: any /** TODO #9100 */): void {
|
||||
getDOM().dispatchEvent(element, getDOM().createEvent(eventType));
|
||||
}
|
||||
|
||||
@ -66,14 +66,14 @@ export function normalizeCSS(css: string): string {
|
||||
css = StringWrapper.replaceAll(css, /'/g, '"');
|
||||
css = StringWrapper.replaceAll(css, / }/g, '}');
|
||||
css = StringWrapper.replaceAllMapped(css, /url\((\"|\s)(.+)(\"|\s)\)(\s*)/g,
|
||||
(match) => `url("${match[2]}")`);
|
||||
(match: any /** TODO #9100 */) => `url("${match[2]}")`);
|
||||
css = StringWrapper.replaceAllMapped(css, /\[(.+)=([^"\]]+)\]/g,
|
||||
(match) => `[${match[1]}="${match[2]}"]`);
|
||||
(match: any /** TODO #9100 */) => `[${match[1]}="${match[2]}"]`);
|
||||
return css;
|
||||
}
|
||||
|
||||
var _singleTagWhitelist = ['br', 'hr', 'input'];
|
||||
export function stringifyElement(el): string {
|
||||
export function stringifyElement(el: any /** TODO #9100 */): string {
|
||||
var result = '';
|
||||
if (getDOM().isElementNode(el)) {
|
||||
var tagName = getDOM().tagName(el).toLowerCase();
|
||||
@ -83,7 +83,7 @@ export function stringifyElement(el): string {
|
||||
|
||||
// Attributes in an ordered way
|
||||
var attributeMap = getDOM().attributeMap(el);
|
||||
var keys = [];
|
||||
var keys: any[] /** TODO #9100 */ = [];
|
||||
attributeMap.forEach((v, k) => keys.push(k));
|
||||
ListWrapper.sort(keys);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
|
@ -9,7 +9,7 @@ import {el} from './browser_util';
|
||||
*/
|
||||
@Injectable()
|
||||
export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||
constructor(@Inject(DOCUMENT) private _doc) { super(); }
|
||||
constructor(@Inject(DOCUMENT) private _doc: any /** TODO #9100 */) { super(); }
|
||||
|
||||
insertRootElement(rootElId: string) {
|
||||
let rootEl = el(`<div id="${rootElId}"></div>`);
|
||||
|
@ -1,12 +1,12 @@
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
|
||||
declare var global;
|
||||
declare var global: any /** TODO #9100 */;
|
||||
declare var expect: Function;
|
||||
export var browser: protractor.IBrowser = global['browser'];
|
||||
export var $: cssSelectorHelper = global['$'];
|
||||
|
||||
export function clickAll(buttonSelectors) {
|
||||
buttonSelectors.forEach(function(selector) { $(selector).click(); });
|
||||
export function clickAll(buttonSelectors: any /** TODO #9100 */) {
|
||||
buttonSelectors.forEach(function(selector: any /** TODO #9100 */) { $(selector).click(); });
|
||||
}
|
||||
|
||||
export function verifyNoBrowserErrors() {
|
||||
|
@ -109,13 +109,13 @@ export var expect: (actual: any) => NgMatchers = <any>_global.expect;
|
||||
// gives us bad error messages in tests.
|
||||
// The only way to do this in Jasmine is to monkey patch a method
|
||||
// to the object :-(
|
||||
Map.prototype['jasmineToString'] = function() {
|
||||
(Map as any /** TODO #???? */).prototype['jasmineToString'] = function() {
|
||||
var m = this;
|
||||
if (!m) {
|
||||
return '' + m;
|
||||
}
|
||||
var res = [];
|
||||
m.forEach((v, k) => { res.push(`${k}:${v}`); });
|
||||
var res: any[] /** TODO #???? */ = [];
|
||||
m.forEach((v: any /** TODO #???? */, k: any /** TODO #???? */) => { res.push(`${k}:${v}`); });
|
||||
return `{ ${res.join(',')} }`;
|
||||
};
|
||||
|
||||
@ -124,16 +124,16 @@ _global.beforeEach(function() {
|
||||
// Custom handler for Map as Jasmine does not support it yet
|
||||
toEqual: function(util, customEqualityTesters) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
compare: function(actual: any /** TODO #???? */, expected: any /** TODO #???? */) {
|
||||
return {pass: util.equals(actual, expected, [compareMap])};
|
||||
}
|
||||
};
|
||||
|
||||
function compareMap(actual, expected) {
|
||||
function compareMap(actual: any /** TODO #???? */, expected: any /** TODO #???? */) {
|
||||
if (actual instanceof Map) {
|
||||
var pass = actual.size === expected.size;
|
||||
if (pass) {
|
||||
actual.forEach((v, k) => { pass = pass && util.equals(v, expected.get(k)); });
|
||||
actual.forEach((v: any /** TODO #???? */, k: any /** TODO #???? */) => { pass = pass && util.equals(v, expected.get(k)); });
|
||||
}
|
||||
return pass;
|
||||
} else {
|
||||
@ -144,7 +144,7 @@ _global.beforeEach(function() {
|
||||
|
||||
toBePromise: function() {
|
||||
return {
|
||||
compare: function(actual, expectedClass) {
|
||||
compare: function(actual: any /** TODO #???? */, expectedClass: any /** TODO #???? */) {
|
||||
var pass = typeof actual === 'object' && typeof actual.then === 'function';
|
||||
return {pass: pass, get message() { return 'Expected ' + actual + ' to be a promise'; }};
|
||||
}
|
||||
@ -153,7 +153,7 @@ _global.beforeEach(function() {
|
||||
|
||||
toBeAnInstanceOf: function() {
|
||||
return {
|
||||
compare: function(actual, expectedClass) {
|
||||
compare: function(actual: any /** TODO #???? */, expectedClass: any /** TODO #???? */) {
|
||||
var pass = typeof actual === 'object' && actual instanceof expectedClass;
|
||||
return {
|
||||
pass: pass,
|
||||
@ -167,7 +167,7 @@ _global.beforeEach(function() {
|
||||
|
||||
toHaveText: function() {
|
||||
return {
|
||||
compare: function(actual, expectedText) {
|
||||
compare: function(actual: any /** TODO #???? */, expectedText: any /** TODO #???? */) {
|
||||
var actualText = elementText(actual);
|
||||
return {
|
||||
pass: actualText == expectedText,
|
||||
@ -180,8 +180,8 @@ _global.beforeEach(function() {
|
||||
toHaveCssClass: function() {
|
||||
return {compare: buildError(false), negativeCompare: buildError(true)};
|
||||
|
||||
function buildError(isNot) {
|
||||
return function(actual, className) {
|
||||
function buildError(isNot: any /** TODO #???? */) {
|
||||
return function(actual: any /** TODO #???? */, className: any /** TODO #???? */) {
|
||||
return {
|
||||
pass: getDOM().hasClass(actual, className) == !isNot,
|
||||
get message() {
|
||||
@ -194,13 +194,13 @@ _global.beforeEach(function() {
|
||||
|
||||
toHaveCssStyle: function() {
|
||||
return {
|
||||
compare: function(actual, styles) {
|
||||
var allPassed;
|
||||
compare: function(actual: any /** TODO #???? */, styles: any /** TODO #???? */) {
|
||||
var allPassed: any /** TODO #???? */;
|
||||
if (isString(styles)) {
|
||||
allPassed = getDOM().hasStyle(actual, styles);
|
||||
} else {
|
||||
allPassed = !StringMapWrapper.isEmpty(styles);
|
||||
StringMapWrapper.forEach(styles, (style, prop) => {
|
||||
StringMapWrapper.forEach(styles, (style: any /** TODO #???? */, prop: any /** TODO #???? */) => {
|
||||
allPassed = allPassed && getDOM().hasStyle(actual, prop, style);
|
||||
});
|
||||
}
|
||||
@ -219,7 +219,7 @@ _global.beforeEach(function() {
|
||||
|
||||
toContainError: function() {
|
||||
return {
|
||||
compare: function(actual, expectedText) {
|
||||
compare: function(actual: any /** TODO #???? */, expectedText: any /** TODO #???? */) {
|
||||
var errorMessage = actual.toString();
|
||||
return {
|
||||
pass: errorMessage.indexOf(expectedText) > -1,
|
||||
@ -231,7 +231,7 @@ _global.beforeEach(function() {
|
||||
|
||||
toThrowErrorWith: function() {
|
||||
return {
|
||||
compare: function(actual, expectedText) {
|
||||
compare: function(actual: any /** TODO #???? */, expectedText: any /** TODO #???? */) {
|
||||
try {
|
||||
actual();
|
||||
return {
|
||||
@ -252,8 +252,8 @@ _global.beforeEach(function() {
|
||||
toMatchPattern() {
|
||||
return {compare: buildError(false), negativeCompare: buildError(true)};
|
||||
|
||||
function buildError(isNot) {
|
||||
return function(actual, regex) {
|
||||
function buildError(isNot: any /** TODO #???? */) {
|
||||
return function(actual: any /** TODO #???? */, regex: any /** TODO #???? */) {
|
||||
return {
|
||||
pass: regex.test(actual) == !isNot,
|
||||
get message() {
|
||||
@ -266,11 +266,11 @@ _global.beforeEach(function() {
|
||||
|
||||
toImplement: function() {
|
||||
return {
|
||||
compare: function(actualObject, expectedInterface) {
|
||||
compare: function(actualObject: any /** TODO #???? */, expectedInterface: any /** TODO #???? */) {
|
||||
var objProps = Object.keys(actualObject.constructor.prototype);
|
||||
var intProps = Object.keys(expectedInterface.prototype);
|
||||
|
||||
var missedMethods = [];
|
||||
var missedMethods: any[] /** TODO #???? */ = [];
|
||||
intProps.forEach((k) => {
|
||||
if (!actualObject.constructor.prototype[k]) missedMethods.push(k);
|
||||
});
|
||||
@ -288,8 +288,8 @@ _global.beforeEach(function() {
|
||||
});
|
||||
});
|
||||
|
||||
function elementText(n) {
|
||||
var hasNodes = (n) => {
|
||||
function elementText(n: any /** TODO #???? */): any /** TODO #???? */ {
|
||||
var hasNodes = (n: any /** TODO #???? */) => {
|
||||
var children = getDOM().childNodes(n);
|
||||
return children && children.length > 0;
|
||||
};
|
||||
|
@ -1,32 +1,32 @@
|
||||
export {verifyNoBrowserErrors} from './e2e_util';
|
||||
|
||||
var benchpress = global['benchpress'];
|
||||
var benchpress = (global as any /** TODO #9100 */)['benchpress'];
|
||||
var bind = benchpress.bind;
|
||||
var Options = benchpress.Options;
|
||||
|
||||
export function runClickBenchmark(config) {
|
||||
export function runClickBenchmark(config: any /** TODO #9100 */) {
|
||||
browser.ignoreSynchronization = !config.waitForAngular2;
|
||||
var buttons = config.buttons.map(function(selector) { return $(selector); });
|
||||
config.work = function() { buttons.forEach(function(button) { button.click(); }); };
|
||||
var buttons = config.buttons.map(function(selector: any /** TODO #9100 */) { return $(selector); });
|
||||
config.work = function() { buttons.forEach(function(button: any /** TODO #9100 */) { button.click(); }); };
|
||||
return runBenchmark(config);
|
||||
}
|
||||
|
||||
export function runBenchmark(config) {
|
||||
export function runBenchmark(config: any /** TODO #9100 */) {
|
||||
return getScaleFactor(browser.params.benchmark.scaling)
|
||||
.then(function(scaleFactor) {
|
||||
var description = {};
|
||||
var urlParams = [];
|
||||
var urlParams: any[] /** TODO #9100 */ = [];
|
||||
if (config.params) {
|
||||
config.params.forEach(function(param) {
|
||||
config.params.forEach(function(param: any /** TODO #9100 */) {
|
||||
var name = param.name;
|
||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||
urlParams.push(name + '=' + value);
|
||||
description[name] = value;
|
||||
(description as any /** TODO #9100 */)[name] = value;
|
||||
});
|
||||
}
|
||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||
return browser.get(url).then(function() {
|
||||
return global['benchpressRunner'].sample({
|
||||
return (global as any /** TODO #9100 */)['benchpressRunner'].sample({
|
||||
id: config.id,
|
||||
execute: config.work,
|
||||
prepare: config.prepare,
|
||||
@ -37,11 +37,11 @@ export function runBenchmark(config) {
|
||||
});
|
||||
}
|
||||
|
||||
function getScaleFactor(possibleScalings) {
|
||||
function getScaleFactor(possibleScalings: any /** TODO #9100 */) {
|
||||
return browser.executeScript('return navigator.userAgent')
|
||||
.then(function(userAgent: string) {
|
||||
var scaleFactor = 1;
|
||||
possibleScalings.forEach(function(entry) {
|
||||
possibleScalings.forEach(function(entry: any /** TODO #9100 */) {
|
||||
if (userAgent.match(entry.userAgent)) {
|
||||
scaleFactor = entry.value;
|
||||
}
|
||||
@ -50,7 +50,7 @@ function getScaleFactor(possibleScalings) {
|
||||
});
|
||||
}
|
||||
|
||||
function applyScaleFactor(value, scaleFactor, method) {
|
||||
function applyScaleFactor(value: any /** TODO #9100 */, scaleFactor: any /** TODO #9100 */, method: any /** TODO #9100 */) {
|
||||
if (method === 'log2') {
|
||||
return value + Math.log(scaleFactor) / Math.LN2;
|
||||
} else if (method === 'sqrt') {
|
||||
|
Reference in New Issue
Block a user