tsconfig: started on setting noImplicitThis to true

This commit is contained in:
Torkel Ödegaard 2018-08-30 08:53:13 +02:00
parent ceadced6f0
commit 80d6ef535d
9 changed files with 37 additions and 51 deletions

View File

@ -1,7 +1,7 @@
// Based on underscore.js debounce() // Based on underscore.js debounce()
export default function debounce(func, wait) { export default function debounce(func, wait) {
let timeout; let timeout;
return function() { return function(this: any) {
const context = this; const context = this;
const args = arguments; const args = arguments;
const later = function() { const later = function() {

View File

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

View File

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

View File

@ -39,15 +39,12 @@ export default class OpenTsDatasource {
const end = this.convertToTSDBTime(options.rangeRaw.to, true); const end = this.convertToTSDBTime(options.rangeRaw.to, true);
const qs = []; const qs = [];
_.each( _.each(options.targets, target => {
options.targets, if (!target.metric) {
function(target) { return;
if (!target.metric) { }
return; qs.push(this.convertTargetToQuery(target, options, this.tsdbVersion));
} });
qs.push(this.convertTargetToQuery(target, options, this.tsdbVersion));
}.bind(this)
);
const queries = _.compact(qs); const queries = _.compact(qs);
@ -75,30 +72,19 @@ export default class OpenTsDatasource {
return query.hide !== true; return query.hide !== true;
}); });
return this.performTimeSeriesQuery(queries, start, end).then( return this.performTimeSeriesQuery(queries, start, end).then(response => {
function(response) { const metricToTargetMapping = this.mapMetricsToTargets(response.data, options, this.tsdbVersion);
const metricToTargetMapping = this.mapMetricsToTargets(response.data, options, this.tsdbVersion); const result = _.map(response.data, (metricData, index) => {
const result = _.map( index = metricToTargetMapping[index];
response.data, if (index === -1) {
function(metricData, index) { index = 0;
index = metricToTargetMapping[index]; }
if (index === -1) { this._saveTagKeys(metricData);
index = 0;
}
this._saveTagKeys(metricData);
return this.transformMetricData( return this.transformMetricData(metricData, groupByTags, options.targets[index], options, this.tsdbResolution);
metricData, });
groupByTags, return { data: result };
options.targets[index], });
options,
this.tsdbResolution
);
}.bind(this)
);
return { data: result };
}.bind(this)
);
} }
annotationQuery(options) { annotationQuery(options) {

View File

@ -1,7 +1,7 @@
import $ from 'jquery'; import $ from 'jquery';
import { appEvents } from 'app/core/core'; import { appEvents } from 'app/core/core';
export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) { export default function GraphTooltip(this: any, elem, dashboard, scope, getSeriesFn) {
const self = this; const self = this;
const ctrl = scope.ctrl; const ctrl = scope.ctrl;
const panel = ctrl.panel; const panel = ctrl.panel;

View File

@ -420,7 +420,7 @@ export class EventMarkers {
event: event, event: event,
}); });
const mouseenter = function() { const mouseenter = function(this: any) {
createAnnotationToolip(marker, $(this).data('event'), that._plot); createAnnotationToolip(marker, $(this).data('event'), that._plot);
}; };
@ -541,7 +541,7 @@ export class EventMarkers {
event: event, event: event,
}); });
const mouseenter = function() { const mouseenter = function(this: any) {
createAnnotationToolip(region, $(this).data('event'), that._plot); createAnnotationToolip(region, $(this).data('event'), that._plot);
}; };
@ -596,7 +596,7 @@ export class EventMarkers {
*/ */
/** @ngInject */ /** @ngInject */
export function init(plot) { export function init(this: any, plot) {
/*jshint validthis:true */ /*jshint validthis:true */
const that = this; const that = this;
const eventMarkers = new EventMarkers(plot); const eventMarkers = new EventMarkers(plot);

View File

@ -31,7 +31,7 @@ export const TeamModel = types
groups: types.optional(types.map(TeamGroupModel), {}), groups: types.optional(types.map(TeamGroupModel), {}),
}) })
.views(self => ({ .views(self => ({
get filteredMembers() { get filteredMembers(this: Team) {
const members = this.members.values(); const members = this.members.values();
const regex = new RegExp(self.search, 'i'); const regex = new RegExp(self.search, 'i');
return members.filter(member => { return members.filter(member => {
@ -121,7 +121,7 @@ export const TeamsStore = types
search: types.optional(types.string, ''), search: types.optional(types.string, ''),
}) })
.views(self => ({ .views(self => ({
get filteredTeams() { get filteredTeams(this: any) {
const teams = this.map.values(); const teams = this.map.values();
const regex = new RegExp(self.search, 'i'); const regex = new RegExp(self.search, 'i');
return teams.filter(team => { return teams.filter(team => {

View File

@ -4,7 +4,7 @@ import * as dateMath from 'app/core/utils/datemath';
import { angularMocks, sinon } from '../lib/common'; import { angularMocks, sinon } from '../lib/common';
import { PanelModel } from 'app/features/dashboard/panel_model'; import { PanelModel } from 'app/features/dashboard/panel_model';
export function ControllerTestContext() { export function ControllerTestContext(this: any) {
const self = this; const self = this;
this.datasource = {}; this.datasource = {};
@ -106,7 +106,7 @@ export function ControllerTestContext() {
}; };
} }
export function ServiceTestContext() { export function ServiceTestContext(this: any) {
const self = this; const self = this;
self.templateSrv = new TemplateSrvStub(); self.templateSrv = new TemplateSrvStub();
self.timeSrv = new TimeSrvStub(); self.timeSrv = new TimeSrvStub();
@ -138,11 +138,11 @@ export function ServiceTestContext() {
}; };
} }
export function DashboardViewStateStub() { export function DashboardViewStateStub(this: any) {
this.registerPanel = function() {}; this.registerPanel = function() {};
} }
export function TimeSrvStub() { export function TimeSrvStub(this: any) {
this.init = sinon.spy(); this.init = sinon.spy();
this.time = { from: 'now-1h', to: 'now' }; this.time = { from: 'now-1h', to: 'now' };
this.timeRange = function(parse) { this.timeRange = function(parse) {
@ -164,13 +164,13 @@ export function TimeSrvStub() {
}; };
} }
export function ContextSrvStub() { export function ContextSrvStub(this: any) {
this.hasRole = function() { this.hasRole = function() {
return true; return true;
}; };
} }
export function TemplateSrvStub() { export function TemplateSrvStub(this: any) {
this.variables = []; this.variables = [];
this.templateSettings = { interpolate: /\[\[([\s\S]+?)\]\]/g }; this.templateSettings = { interpolate: /\[\[([\s\S]+?)\]\]/g };
this.data = {}; this.data = {};

View File

@ -20,7 +20,7 @@
"emitDecoratorMetadata": false, "emitDecoratorMetadata": false,
"experimentalDecorators": true, "experimentalDecorators": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"noImplicitThis": false, "noImplicitThis": true,
"noImplicitUseStrict": false, "noImplicitUseStrict": false,
"noImplicitAny": false, "noImplicitAny": false,
"noUnusedLocals": true, "noUnusedLocals": true,