noImplicitAny: 1670 errors (#18035)

* Sub 2000 errors

* Down to 1670 errors

* Minor fixes
This commit is contained in:
Tobias Skarhed
2019-07-11 17:05:45 +02:00
committed by Torkel Ödegaard
parent 6aa58182c7
commit e1cec1069c
34 changed files with 300 additions and 271 deletions

View File

@@ -4,7 +4,7 @@ import { variableRegex } from 'app/features/templating/variable';
import { ScopedVars } from '@grafana/ui';
import { TimeRange } from '@grafana/data';
function luceneEscape(value) {
function luceneEscape(value: string) {
return value.replace(/([\!\*\+\-\=<>\s\&\|\(\)\[\]\{\}\^\~\?\:\\/"])/g, '\\$1');
}
@@ -12,8 +12,8 @@ export class TemplateSrv {
variables: any[];
private regex = variableRegex;
private index = {};
private grafanaVariables = {};
private index: any = {};
private grafanaVariables: any = {};
private builtIns: any = {};
private timeRange: TimeRange = null;
@@ -23,7 +23,7 @@ export class TemplateSrv {
this.variables = [];
}
init(variables, timeRange?: TimeRange) {
init(variables: any, timeRange?: TimeRange) {
this.variables = variables;
this.timeRange = timeRange;
this.updateIndex();
@@ -34,7 +34,7 @@ export class TemplateSrv {
}
updateIndex() {
const existsOrEmpty = value => value || value === '';
const existsOrEmpty = (value: any) => value || value === '';
this.index = this.variables.reduce((acc, currentValue) => {
if (currentValue.current && (currentValue.current.isNone || existsOrEmpty(currentValue.current.value))) {
@@ -64,12 +64,12 @@ export class TemplateSrv {
this.updateIndex();
}
variableInitialized(variable) {
variableInitialized(variable: any) {
this.index[variable.name] = variable;
}
getAdhocFilters(datasourceName) {
let filters = [];
getAdhocFilters(datasourceName: string) {
let filters: any = [];
if (this.variables) {
for (let i = 0; i < this.variables.length; i++) {
@@ -92,7 +92,7 @@ export class TemplateSrv {
return filters;
}
luceneFormat(value) {
luceneFormat(value: any) {
if (typeof value === 'string') {
return luceneEscape(value);
}
@@ -108,7 +108,7 @@ export class TemplateSrv {
// encode string according to RFC 3986; in contrast to encodeURIComponent()
// also the sub-delims "!", "'", "(", ")" and "*" are encoded;
// unicode handling uses UTF-8 as in ECMA-262.
encodeURIComponentStrict(str) {
encodeURIComponentStrict(str: string) {
return encodeURIComponent(str).replace(/[!'()*]/g, c => {
return (
'%' +
@@ -120,7 +120,7 @@ export class TemplateSrv {
});
}
formatValue(value, format, variable) {
formatValue(value: any, format: any, variable: any) {
// for some scopedVars there is no variable
variable = variable || {};
@@ -180,11 +180,11 @@ export class TemplateSrv {
}
}
setGrafanaVariable(name, value) {
setGrafanaVariable(name: string, value: any) {
this.grafanaVariables[name] = value;
}
getVariableName(expression) {
getVariableName(expression: string) {
this.regex.lastIndex = 0;
const match = this.regex.exec(expression);
if (!match) {
@@ -194,12 +194,12 @@ export class TemplateSrv {
return variableName;
}
variableExists(expression) {
variableExists(expression: string) {
const name = this.getVariableName(expression);
return name && this.index[name] !== void 0;
}
highlightVariablesAsHtml(str) {
highlightVariablesAsHtml(str: string) {
if (!str || !_.isString(str)) {
return str;
}
@@ -214,7 +214,7 @@ export class TemplateSrv {
});
}
getAllValue(variable) {
getAllValue(variable: any) {
if (variable.allValue) {
return variable.allValue;
}
@@ -225,7 +225,7 @@ export class TemplateSrv {
return values;
}
replace(target: string, scopedVars?: ScopedVars, format?: string | Function) {
replace(target: string, scopedVars?: ScopedVars, format?: string | Function): any {
if (!target) {
return target;
}
@@ -266,11 +266,11 @@ export class TemplateSrv {
});
}
isAllValue(value) {
isAllValue(value: any) {
return value === '$__all' || (Array.isArray(value) && value[0] === '$__all');
}
replaceWithText(target, scopedVars) {
replaceWithText(target: string, scopedVars: ScopedVars) {
if (!target) {
return target;
}
@@ -278,7 +278,7 @@ export class TemplateSrv {
let variable;
this.regex.lastIndex = 0;
return target.replace(this.regex, (match, var1, var2, fmt2, var3) => {
return target.replace(this.regex, (match: any, var1: any, var2: any, fmt2: any, var3: any) => {
if (scopedVars) {
const option = scopedVars[var1 || var2 || var3];
if (option) {
@@ -297,7 +297,7 @@ export class TemplateSrv {
});
}
fillVariableValuesForUrl(params, scopedVars?) {
fillVariableValuesForUrl(params: any, scopedVars?: ScopedVars) {
_.each(this.variables, variable => {
if (scopedVars && scopedVars[variable.name] !== void 0) {
if (scopedVars[variable.name].skipUrlSync) {
@@ -313,7 +313,7 @@ export class TemplateSrv {
});
}
distributeVariable(value, variable) {
distributeVariable(value: any, variable: any) {
value = _.map(value, (val: any, index: number) => {
if (index !== 0) {
return variable + '=' + val;

View File

@@ -16,12 +16,12 @@ export const variableRegexExec = (variableString: string) => {
};
export interface Variable {
setValue(option);
updateOptions();
dependsOn(variable);
setValueFromUrl(urlValue);
getValueForUrl();
getSaveModel();
setValue(option: any): any;
updateOptions(): any;
dependsOn(variable: any): any;
setValueFromUrl(urlValue: any): any;
getValueForUrl(): any;
getSaveModel(): any;
}
export let variableTypes = {};

View File

@@ -1,5 +1,5 @@
// Libaries
import angular from 'angular';
import angular, { IQService, ILocationService, auto, IPromise } from 'angular';
import _ from 'lodash';
// Utils & Services
@@ -19,9 +19,9 @@ export class VariableSrv {
/** @ngInject */
constructor(
private $q,
private $location,
private $injector,
private $q: IQService,
private $location: ILocationService,
private $injector: auto.IInjectorService,
private templateSrv: TemplateSrv,
private timeSrv: TimeSrv
) {}
@@ -71,7 +71,7 @@ export class VariableSrv {
});
}
processVariable(variable, queryParams) {
processVariable(variable: any, queryParams: any) {
const dependencies = [];
for (const otherVariable of this.variables) {
@@ -100,7 +100,8 @@ export class VariableSrv {
});
}
createVariableFromModel(model) {
createVariableFromModel(model: any) {
// @ts-ignore
const ctor = variableTypes[model.type].ctor;
if (!ctor) {
throw {
@@ -112,24 +113,24 @@ export class VariableSrv {
return variable;
}
addVariable(variable) {
addVariable(variable: any) {
this.variables.push(variable);
this.templateSrv.updateIndex();
this.dashboard.updateSubmenuVisibility();
}
removeVariable(variable) {
removeVariable(variable: any) {
const index = _.indexOf(this.variables, variable);
this.variables.splice(index, 1);
this.templateSrv.updateIndex();
this.dashboard.updateSubmenuVisibility();
}
updateOptions(variable) {
updateOptions(variable: any) {
return variable.updateOptions();
}
variableUpdated(variable, emitChangeEvents?) {
variableUpdated(variable: any, emitChangeEvents?: any) {
// if there is a variable lock ignore cascading update because we are in a boot up scenario
if (variable.initLock) {
return this.$q.when();
@@ -152,7 +153,7 @@ export class VariableSrv {
});
}
selectOptionsForCurrentValue(variable) {
selectOptionsForCurrentValue(variable: any) {
let i, y, value, option;
const selected: any = [];
@@ -176,7 +177,7 @@ export class VariableSrv {
return selected;
}
validateVariableSelectionState(variable) {
validateVariableSelectionState(variable: any) {
if (!variable.current) {
variable.current = {};
}
@@ -221,7 +222,7 @@ export class VariableSrv {
* @param variable Instance of Variable
* @param urlValue Value of the query parameter
*/
setOptionFromUrl(variable: any, urlValue: string | string[]): Promise<any> {
setOptionFromUrl(variable: any, urlValue: string | string[]): IPromise<any> {
let promise = this.$q.when();
if (variable.refresh) {
@@ -268,7 +269,7 @@ export class VariableSrv {
});
}
setOptionAsCurrent(variable, option) {
setOptionAsCurrent(variable: any, option: any) {
variable.current = _.cloneDeep(option);
if (_.isArray(variable.current.text) && variable.current.text.length > 0) {
@@ -298,7 +299,7 @@ export class VariableSrv {
this.$location.search(params);
}
setAdhocFilter(options) {
setAdhocFilter(options: any) {
let variable: any = _.find(this.variables, {
type: 'adhoc',
datasource: options.datasource,