Merge branch 'tsconfig-no-implicit-this'

This commit is contained in:
Torkel Ödegaard
2018-08-30 11:46:13 +02:00
27 changed files with 90 additions and 113 deletions

View File

@@ -90,7 +90,7 @@ export function graphiteAddFunc($compile) {
};
$(elem)
.on('mouseenter', 'ul.dropdown-menu li', function() {
.on('mouseenter', 'ul.dropdown-menu li', () => {
cleanUpDrop();
let funcDef;

View File

@@ -4,7 +4,7 @@ import { isVersionGtOrEq, SemVersion } from 'app/core/utils/version';
import gfunc from './gfunc';
/** @ngInject */
export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv) {
export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv, templateSrv) {
this.basicAuth = instanceSettings.basicAuth;
this.url = instanceSettings.url;
this.name = instanceSettings.name;

View File

@@ -28,7 +28,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
let paramCountAtLink = 0;
let cancelBlur = null;
function clickFuncParam(paramIndex) {
function clickFuncParam(this: any, paramIndex) {
/*jshint validthis:true */
const $link = $(this);
@@ -108,7 +108,7 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
}
// this = input element
function inputBlur(paramIndex) {
function inputBlur(this: any, paramIndex) {
/*jshint validthis:true */
const inputElem = this;
// happens long before the click event on the typeahead options
@@ -118,14 +118,14 @@ export function graphiteFuncEditor($compile, templateSrv, popoverSrv) {
}, 200);
}
function inputKeyPress(paramIndex, e) {
function inputKeyPress(this: any, paramIndex, e) {
/*jshint validthis:true */
if (e.which === 13) {
$(this).blur();
}
}
function inputKeyDown() {
function inputKeyDown(this: any) {
/*jshint validthis:true */
this.style.width = (3 + this.value.length) * 8 + 'px';
}

View File

@@ -964,26 +964,23 @@ export class FuncInstance {
render(metricExp) {
const str = this.def.name + '(';
const parameters = _.map(
this.params,
function(value, index) {
let paramType;
if (index < this.def.params.length) {
paramType = this.def.params[index].type;
} else if (_.get(_.last(this.def.params), 'multiple')) {
paramType = _.get(_.last(this.def.params), 'type');
}
// param types that should never be quoted
if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
return value;
}
// param types that might be quoted
if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
return _.toString(+value);
}
return "'" + value + "'";
}.bind(this)
);
const parameters = _.map(this.params, (value, index) => {
let paramType;
if (index < this.def.params.length) {
paramType = this.def.params[index].type;
} else if (_.get(_.last(this.def.params), 'multiple')) {
paramType = _.get(_.last(this.def.params), 'type');
}
// param types that should never be quoted
if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
return value;
}
// param types that might be quoted
if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
return _.toString(+value);
}
return "'" + value + "'";
});
// don't send any blank parameters to graphite
while (parameters[parameters.length - 1] === '') {
@@ -1017,12 +1014,9 @@ export class FuncInstance {
// handle optional parameters
// if string contains ',' and next param is optional, split and update both
if (this._hasMultipleParamsInString(strValue, index)) {
_.each(
strValue.split(','),
function(partVal, idx) {
this.updateParam(partVal.trim(), index + idx);
}.bind(this)
);
_.each(strValue.split(','), (partVal, idx) => {
this.updateParam(partVal.trim(), index + idx);
});
return;
}

View File

@@ -922,7 +922,7 @@ for (let i = 0; i < 128; i++) {
const identifierPartTable = identifierStartTable;
export function Lexer(expression) {
export function Lexer(this: any, expression) {
this.input = expression;
this.char = 1;
this.from = 1;
@@ -1037,7 +1037,7 @@ Lexer.prototype = {
return /^[0-9a-fA-F]$/.test(str);
}
const readUnicodeEscapeSequence = _.bind(function() {
const readUnicodeEscapeSequence = _.bind(function(this: any) {
/*jshint validthis:true */
index += 1;
@@ -1065,7 +1065,7 @@ Lexer.prototype = {
return null;
}, this);
const getIdentifierStart = _.bind(function() {
const getIdentifierStart = _.bind(function(this: any) {
/*jshint validthis:true */
const chr = this.peek(index);
const code = chr.charCodeAt(0);
@@ -1096,7 +1096,7 @@ Lexer.prototype = {
return null;
}, this);
const getIdentifierPart = _.bind(function() {
const getIdentifierPart = _.bind(function(this: any) {
/*jshint validthis:true */
const chr = this.peek(index);
const code = chr.charCodeAt(0);

View File

@@ -1,6 +1,6 @@
import { Lexer } from './lexer';
export function Parser(expression) {
export function Parser(this: any, expression) {
this.expression = expression;
this.lexer = new Lexer(expression);
this.tokens = this.lexer.tokenize();