Skip to content

Commit

Permalink
tsconfig: started on setting noImplicitThis to true
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Aug 30, 2018
1 parent ceadced commit 80d6ef5
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 52 deletions.
2 changes: 1 addition & 1 deletion public/app/containers/Explore/utils/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Based on underscore.js debounce()
export default function debounce(func, wait) {
let timeout;
return function() {
return function(this: any) {
const context = this;
const args = arguments;
const later = function() {
Expand Down
8 changes: 4 additions & 4 deletions public/app/plugins/datasource/graphite/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ for (var 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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion public/app/plugins/datasource/graphite/parser.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
52 changes: 19 additions & 33 deletions public/app/plugins/datasource/opentsdb/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ export default class OpenTsDatasource {
const end = this.convertToTSDBTime(options.rangeRaw.to, true);
const qs = [];

_.each(
options.targets,
function(target) {
if (!target.metric) {
return;
}
qs.push(this.convertTargetToQuery(target, options, this.tsdbVersion));
}.bind(this)
);
_.each(options.targets, target => {
if (!target.metric) {
return;
}
qs.push(this.convertTargetToQuery(target, options, this.tsdbVersion));
});

const queries = _.compact(qs);

Expand Down Expand Up @@ -75,30 +72,19 @@ export default class OpenTsDatasource {
return query.hide !== true;
});

return this.performTimeSeriesQuery(queries, start, end).then(
function(response) {
const metricToTargetMapping = this.mapMetricsToTargets(response.data, options, this.tsdbVersion);
const result = _.map(
response.data,
function(metricData, index) {
index = metricToTargetMapping[index];
if (index === -1) {
index = 0;
}
this._saveTagKeys(metricData);

return this.transformMetricData(
metricData,
groupByTags,
options.targets[index],
options,
this.tsdbResolution
);
}.bind(this)
);
return { data: result };
}.bind(this)
);
return this.performTimeSeriesQuery(queries, start, end).then(response => {
const metricToTargetMapping = this.mapMetricsToTargets(response.data, options, this.tsdbVersion);
const result = _.map(response.data, (metricData, index) => {
index = metricToTargetMapping[index];
if (index === -1) {
index = 0;
}
this._saveTagKeys(metricData);

return this.transformMetricData(metricData, groupByTags, options.targets[index], options, this.tsdbResolution);
});
return { data: result };
});
}

annotationQuery(options) {
Expand Down
2 changes: 1 addition & 1 deletion public/app/plugins/panel/graph/graph_tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'jquery';
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 ctrl = scope.ctrl;
const panel = ctrl.panel;
Expand Down
6 changes: 3 additions & 3 deletions public/app/plugins/panel/graph/jquery.flot.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class EventMarkers {
event: event,
});

const mouseenter = function() {
const mouseenter = function(this: any) {
createAnnotationToolip(marker, $(this).data('event'), that._plot);
};

Expand Down Expand Up @@ -541,7 +541,7 @@ export class EventMarkers {
event: event,
});

const mouseenter = function() {
const mouseenter = function(this: any) {
createAnnotationToolip(region, $(this).data('event'), that._plot);
};

Expand Down Expand Up @@ -596,7 +596,7 @@ export class EventMarkers {
*/

/** @ngInject */
export function init(plot) {
export function init(this: any, plot) {
/*jshint validthis:true */
const that = this;
const eventMarkers = new EventMarkers(plot);
Expand Down
4 changes: 2 additions & 2 deletions public/app/stores/TeamsStore/TeamsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const TeamModel = types
groups: types.optional(types.map(TeamGroupModel), {}),
})
.views(self => ({
get filteredMembers() {
get filteredMembers(this: Team) {
const members = this.members.values();
const regex = new RegExp(self.search, 'i');
return members.filter(member => {
Expand Down Expand Up @@ -121,7 +121,7 @@ export const TeamsStore = types
search: types.optional(types.string, ''),
})
.views(self => ({
get filteredTeams() {
get filteredTeams(this: any) {
const teams = this.map.values();
const regex = new RegExp(self.search, 'i');
return teams.filter(team => {
Expand Down
12 changes: 6 additions & 6 deletions public/test/specs/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as dateMath from 'app/core/utils/datemath';
import { angularMocks, sinon } from '../lib/common';
import { PanelModel } from 'app/features/dashboard/panel_model';

export function ControllerTestContext() {
export function ControllerTestContext(this: any) {
const self = this;

this.datasource = {};
Expand Down Expand Up @@ -106,7 +106,7 @@ export function ControllerTestContext() {
};
}

export function ServiceTestContext() {
export function ServiceTestContext(this: any) {
const self = this;
self.templateSrv = new TemplateSrvStub();
self.timeSrv = new TimeSrvStub();
Expand Down Expand Up @@ -138,11 +138,11 @@ export function ServiceTestContext() {
};
}

export function DashboardViewStateStub() {
export function DashboardViewStateStub(this: any) {
this.registerPanel = function() {};
}

export function TimeSrvStub() {
export function TimeSrvStub(this: any) {
this.init = sinon.spy();
this.time = { from: 'now-1h', to: 'now' };
this.timeRange = function(parse) {
Expand All @@ -164,13 +164,13 @@ export function TimeSrvStub() {
};
}

export function ContextSrvStub() {
export function ContextSrvStub(this: any) {
this.hasRole = function() {
return true;
};
}

export function TemplateSrvStub() {
export function TemplateSrvStub(this: any) {
this.variables = [];
this.templateSettings = { interpolate: /\[\[([\s\S]+?)\]\]/g };
this.data = {};
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"noImplicitReturns": true,
"noImplicitThis": false,
"noImplicitThis": true,
"noImplicitUseStrict": false,
"noImplicitAny": false,
"noUnusedLocals": true,
Expand Down

0 comments on commit 80d6ef5

Please sign in to comment.