diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 6ae1a99f245..753f7a5a330 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -84,7 +84,7 @@ function link(scope, elem, attrs) { // disable depreacation warning codeEditor.$blockScrolling = Infinity; // Padding hacks - (codeEditor.renderer).setScrollMargin(15, 15); + (codeEditor.renderer as any).setScrollMargin(15, 15); codeEditor.renderer.setPadding(10); setThemeMode(); @@ -152,7 +152,7 @@ function link(scope, elem, attrs) { if (scope.getCompleter()) { // make copy of array as ace seems to share completers array between instances - const anyEditor = codeEditor; + const anyEditor = codeEditor as any; anyEditor.completers = anyEditor.completers.slice(); anyEditor.completers.push(scope.getCompleter()); } diff --git a/public/app/core/config.ts b/public/app/core/config.ts index 86720ed5dcc..1428dbec74c 100644 --- a/public/app/core/config.ts +++ b/public/app/core/config.ts @@ -51,7 +51,7 @@ export class Settings { } } -const bootData = (window).grafanaBootData || { settings: {} }; +const bootData = (window as any).grafanaBootData || { settings: {} }; const options = bootData.settings; options.bootData = bootData; diff --git a/public/app/core/controllers/inspect_ctrl.ts b/public/app/core/controllers/inspect_ctrl.ts index 612b9cac42e..c55a0d50902 100644 --- a/public/app/core/controllers/inspect_ctrl.ts +++ b/public/app/core/controllers/inspect_ctrl.ts @@ -60,7 +60,7 @@ export class InspectCtrl { if (keyValue[1].length > 0) { result.push({ key: keyValue[0], - value: (window).unescape(keyValue[1]), + value: (window as any).unescape(keyValue[1]), }); } } diff --git a/public/app/core/partials.ts b/public/app/core/partials.ts index 8f8fd040b9f..64b0b11b8ca 100644 --- a/public/app/core/partials.ts +++ b/public/app/core/partials.ts @@ -1,4 +1,4 @@ -let templates = (require).context('../', true, /\.html$/); +let templates = (require as any).context('../', true, /\.html$/); templates.keys().forEach(function(key) { templates(key); }); diff --git a/public/app/core/services/analytics.ts b/public/app/core/services/analytics.ts index c3936f45451..a0faf4016fd 100644 --- a/public/app/core/services/analytics.ts +++ b/public/app/core/services/analytics.ts @@ -12,13 +12,13 @@ export class Analytics { dataType: 'script', cache: true, }); - const ga = ((window).ga = - (window).ga || + const ga = ((window as any).ga = + (window as any).ga || function() { (ga.q = ga.q || []).push(arguments); }); ga.l = +new Date(); - ga('create', (config).googleAnalyticsId, 'auto'); + ga('create', (config as any).googleAnalyticsId, 'auto'); ga('set', 'anonymizeIp', true); return ga; } @@ -26,7 +26,7 @@ export class Analytics { init() { this.$rootScope.$on('$viewContentLoaded', () => { const track = { page: this.$location.url() }; - const ga = (window).ga || this.gaInit(); + const ga = (window as any).ga || this.gaInit(); ga('set', track); ga('send', 'pageview'); }); @@ -35,7 +35,7 @@ export class Analytics { /** @ngInject */ function startAnalytics(googleAnalyticsSrv) { - if ((config).googleAnalyticsId) { + if ((config as any).googleAnalyticsId) { googleAnalyticsSrv.init(); } } diff --git a/public/app/core/specs/manage_dashboards.test.ts b/public/app/core/specs/manage_dashboards.test.ts index 4b51e6848d0..5af0ebade02 100644 --- a/public/app/core/specs/manage_dashboards.test.ts +++ b/public/app/core/specs/manage_dashboards.test.ts @@ -562,5 +562,5 @@ function createCtrlWithStubs(searchResponse: any, tags?: any) { }, }; - return new ManageDashboardsCtrl({}, { getNav: () => {} }, searchSrvStub, { isEditor: true }); + return new ManageDashboardsCtrl({}, { getNav: () => {} }, searchSrvStub as SearchSrv, { isEditor: true }); } diff --git a/public/app/core/specs/search.test.ts b/public/app/core/specs/search.test.ts index 3cc789b3cc5..fa60d373e2f 100644 --- a/public/app/core/specs/search.test.ts +++ b/public/app/core/specs/search.test.ts @@ -12,7 +12,7 @@ describe('SearchCtrl', () => { search: (options: any) => {}, getDashboardTags: () => {}, }; - const ctrl = new SearchCtrl({ $on: () => {} }, {}, {}, searchSrvStub); + const ctrl = new SearchCtrl({ $on: () => {} }, {}, {}, searchSrvStub as SearchSrv); describe('Given an empty result', () => { beforeEach(() => { diff --git a/public/app/features/dashboard/shareModalCtrl.ts b/public/app/features/dashboard/shareModalCtrl.ts index f569f2454dc..27f0e0073a9 100644 --- a/public/app/features/dashboard/shareModalCtrl.ts +++ b/public/app/features/dashboard/shareModalCtrl.ts @@ -94,11 +94,11 @@ export function ShareModalCtrl($scope, $rootScope, $location, $timeout, timeSrv, const utcOffset = '&tz=UTC' + encodeURIComponent(moment().format('Z')); // Older browser does not the internationalization API - if (!(window).Intl) { + if (!(window as any).Intl) { return utcOffset; } - const dateFormat = (window).Intl.DateTimeFormat(); + const dateFormat = (window as any).Intl.DateTimeFormat(); if (!dateFormat.resolvedOptions) { return utcOffset; } diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.test.ts b/public/app/features/dashboard/specs/share_modal_ctrl.test.ts index 796baf7f522..6effc504861 100644 --- a/public/app/features/dashboard/specs/share_modal_ctrl.test.ts +++ b/public/app/features/dashboard/specs/share_modal_ctrl.test.ts @@ -4,7 +4,7 @@ import config from 'app/core/config'; import { LinkSrv } from 'app/features/panellinks/link_srv'; describe('ShareModalCtrl', () => { - const ctx = { + const ctx = { timeSrv: { timeRange: () => { return { from: new Date(1000), to: new Date(2000) }; @@ -26,9 +26,9 @@ describe('ShareModalCtrl', () => { templateSrv: { fillVariableValuesForUrl: () => {}, }, - }; + } as any; - (window).Intl.DateTimeFormat = () => { + (window as any).Intl.DateTimeFormat = () => { return { resolvedOptions: () => { return { timeZone: 'UTC' }; diff --git a/public/app/features/templating/specs/variable_srv.test.ts b/public/app/features/templating/specs/variable_srv.test.ts index 96b3e5b81b6..06317ee1b3a 100644 --- a/public/app/features/templating/specs/variable_srv.test.ts +++ b/public/app/features/templating/specs/variable_srv.test.ts @@ -4,7 +4,7 @@ import moment from 'moment'; import $q from 'q'; describe('VariableSrv', function(this: any) { - const ctx = { + const ctx = { datasourceSrv: {}, timeSrv: { timeRange: () => {}, @@ -29,7 +29,7 @@ describe('VariableSrv', function(this: any) { $location: { search: () => {}, }, - }; + } as any; function describeUpdateVariable(desc, fn) { describe(desc, () => { diff --git a/public/app/features/templating/specs/variable_srv_init.test.ts b/public/app/features/templating/specs/variable_srv_init.test.ts index 978ad824d69..b5d00a5289e 100644 --- a/public/app/features/templating/specs/variable_srv_init.test.ts +++ b/public/app/features/templating/specs/variable_srv_init.test.ts @@ -17,12 +17,12 @@ describe('VariableSrv init', function(this: any) { }), }; - const $injector = {}; + const $injector = {} as any; const $rootscope = { $on: () => {}, }; - let ctx = {}; + let ctx = {} as any; function describeInitScenario(desc, fn) { describe(desc, () => { diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts index 08329ba4e73..db08c1d6f81 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts @@ -25,10 +25,10 @@ describe('CloudWatchDatasource', function() { }, }; const backendSrv = {}; - const ctx = { + const ctx = { backendSrv, templateSrv, - }; + } as any; beforeEach(() => { ctx.ds = new CloudWatchDatasource(instanceSettings, {}, backendSrv, templateSrv, timeSrv); diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts index a54a3f50f86..980fbe14593 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts @@ -33,10 +33,10 @@ describe('ElasticDatasource', function(this: any) { }), }; - const ctx = { + const ctx = { $rootScope, backendSrv, - }; + } as any; function createDatasource(instanceSettings) { instanceSettings.jsonData = instanceSettings.jsonData || {}; diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts index 7826a458968..6a07e44252d 100644 --- a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts +++ b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts @@ -3,7 +3,7 @@ import gfunc from '../gfunc'; import { GraphiteQueryCtrl } from '../query_ctrl'; describe('GraphiteQueryCtrl', () => { - const ctx = { + const ctx = { datasource: { metricFindQuery: jest.fn(() => Promise.resolve([])), getFuncDefs: jest.fn(() => Promise.resolve(gfunc.getFuncDefs('1.0'))), @@ -15,7 +15,7 @@ describe('GraphiteQueryCtrl', () => { panelCtrl: { refresh: jest.fn(), }, - }; + } as any; ctx.panelCtrl.panel = { targets: [ctx.target], diff --git a/public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts b/public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts index 88d4fb143cd..b50c7d8cde6 100644 --- a/public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/query_ctrl.test.ts @@ -3,7 +3,7 @@ import { uiSegmentSrv } from 'app/core/services/segment_srv'; import { InfluxQueryCtrl } from '../query_ctrl'; describe('InfluxDBQueryCtrl', () => { - const ctx = {}; + const ctx = {} as any; beforeEach(() => { InfluxQueryCtrl.prototype.datasource = { diff --git a/public/app/plugins/datasource/mysql/specs/datasource.test.ts b/public/app/plugins/datasource/mysql/specs/datasource.test.ts index e75ba5e32ee..0990be6f21c 100644 --- a/public/app/plugins/datasource/mysql/specs/datasource.test.ts +++ b/public/app/plugins/datasource/mysql/specs/datasource.test.ts @@ -9,9 +9,9 @@ describe('MySQLDatasource', function() { replace: jest.fn(text => text), }; - const ctx = { + const ctx = { backendSrv, - }; + } as any; beforeEach(() => { ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv); diff --git a/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts b/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts index e7e53c0dd5b..64534defc75 100644 --- a/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts +++ b/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts @@ -2,13 +2,13 @@ import OpenTsDatasource from '../datasource'; import $q from 'q'; describe('opentsdb', () => { - const ctx = { + const ctx = { backendSrv: {}, ds: {}, templateSrv: { replace: str => str, }, - }; + } as any; const instanceSettings = { url: '', jsonData: { tsdbVersion: 1 } }; beforeEach(() => { diff --git a/public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts b/public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts index 6fdcd29aecd..eaf20059900 100644 --- a/public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts +++ b/public/app/plugins/datasource/opentsdb/specs/query_ctrl.test.ts @@ -1,14 +1,14 @@ import { OpenTsQueryCtrl } from '../query_ctrl'; describe('OpenTsQueryCtrl', () => { - const ctx = { + const ctx = { target: { target: '' }, datasource: { tsdbVersion: '', getAggregators: () => Promise.resolve([]), getFilterTypes: () => Promise.resolve([]), }, - }; + } as any; ctx.panelCtrl = { panel: { diff --git a/public/app/plugins/datasource/postgres/specs/datasource.test.ts b/public/app/plugins/datasource/postgres/specs/datasource.test.ts index ea150750687..2c0c0554250 100644 --- a/public/app/plugins/datasource/postgres/specs/datasource.test.ts +++ b/public/app/plugins/datasource/postgres/specs/datasource.test.ts @@ -9,9 +9,9 @@ describe('PostgreSQLDatasource', function() { const templateSrv = { replace: jest.fn(text => text), }; - const ctx = { + const ctx = { backendSrv, - }; + } as any; beforeEach(() => { ctx.ds = new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv); diff --git a/public/app/plugins/datasource/prometheus/specs/completer.test.ts b/public/app/plugins/datasource/prometheus/specs/completer.test.ts index 59fcc6592fb..05952e1dc4a 100644 --- a/public/app/plugins/datasource/prometheus/specs/completer.test.ts +++ b/public/app/plugins/datasource/prometheus/specs/completer.test.ts @@ -15,7 +15,7 @@ describe('Prometheus editor completer', function() { const editor = {}; - const backendSrv = {}; + const backendSrv = {} as BackendSrv; const datasourceStub = new PrometheusDatasource({}, {}, backendSrv, {}, {}); datasourceStub.performInstantQuery = jest.fn(() => diff --git a/public/app/plugins/datasource/prometheus/specs/datasource.test.ts b/public/app/plugins/datasource/prometheus/specs/datasource.test.ts index 846a00212d0..35d13684240 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource.test.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource.test.ts @@ -385,7 +385,7 @@ const HOUR = 60 * MINUTE; const time = ({ hours = 0, seconds = 0, minutes = 0 }) => moment(hours * HOUR + minutes * MINUTE + seconds * SECOND); -const ctx = {}; +const ctx = {} as any; const instanceSettings = { url: 'proxied', directUrl: 'direct', @@ -393,9 +393,9 @@ const instanceSettings = { password: 'mupp', jsonData: { httpMethod: 'GET' }, }; -const backendSrv = { +const backendSrv = { datasourceRequest: jest.fn(), -}; +} as any; const templateSrv = { replace: jest.fn(str => str), @@ -435,7 +435,7 @@ describe('PrometheusDatasource', () => { }, }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query).then(function(data) { results = data; @@ -485,7 +485,7 @@ describe('PrometheusDatasource', () => { }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query).then(function(data) { results = data; @@ -546,7 +546,7 @@ describe('PrometheusDatasource', () => { }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query).then(function(data) { results = data; @@ -601,7 +601,7 @@ describe('PrometheusDatasource', () => { }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.annotationQuery(options).then(function(data) { results = data; @@ -641,7 +641,7 @@ describe('PrometheusDatasource', () => { }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query).then(function(data) { results = data; }); @@ -678,7 +678,7 @@ describe('PrometheusDatasource', () => { const urlExpected = 'proxied/api/v1/query_range?query=test&start=60&end=420&step=10'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -694,7 +694,7 @@ describe('PrometheusDatasource', () => { }; const urlExpected = 'proxied/api/v1/query_range?query=test&start=60&end=420&step=1'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -715,7 +715,7 @@ describe('PrometheusDatasource', () => { }; const urlExpected = 'proxied/api/v1/query_range?query=test&start=60&end=420&step=10'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -732,7 +732,7 @@ describe('PrometheusDatasource', () => { const start = 60 * 60; const urlExpected = 'proxied/api/v1/query_range?query=test&start=' + start + '&end=' + end + '&step=2'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -754,7 +754,7 @@ describe('PrometheusDatasource', () => { // times get rounded up to interval const urlExpected = 'proxied/api/v1/query_range?query=test&start=50&end=450&step=50'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -775,7 +775,7 @@ describe('PrometheusDatasource', () => { }; const urlExpected = 'proxied/api/v1/query_range?query=test' + '&start=60&end=420&step=15'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -797,7 +797,7 @@ describe('PrometheusDatasource', () => { // times get aligned to interval const urlExpected = 'proxied/api/v1/query_range?query=test' + '&start=0&end=500&step=100'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -819,7 +819,7 @@ describe('PrometheusDatasource', () => { const start = 0; const urlExpected = 'proxied/api/v1/query_range?query=test' + '&start=' + start + '&end=' + end + '&step=100'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -841,7 +841,7 @@ describe('PrometheusDatasource', () => { const start = 0; const urlExpected = 'proxied/api/v1/query_range?query=test' + '&start=' + start + '&end=' + end + '&step=60'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -884,7 +884,7 @@ describe('PrometheusDatasource', () => { templateSrv.replace = jest.fn(str => str); backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -923,7 +923,7 @@ describe('PrometheusDatasource', () => { '&start=60&end=420&step=10'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); templateSrv.replace = jest.fn(str => str); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -963,7 +963,7 @@ describe('PrometheusDatasource', () => { '&start=0&end=500&step=100'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); templateSrv.replace = jest.fn(str => str); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -1009,7 +1009,7 @@ describe('PrometheusDatasource', () => { templateSrv.replace = jest.fn(str => str); backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -1049,7 +1049,7 @@ describe('PrometheusDatasource', () => { '&start=60&end=420&step=15'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -1094,7 +1094,7 @@ describe('PrometheusDatasource', () => { '&step=60'; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); templateSrv.replace = jest.fn(str => str); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query); const res = backendSrv.datasourceRequest.mock.calls[0][0]; expect(res.method).toBe('GET'); @@ -1155,7 +1155,7 @@ describe('PrometheusDatasource for POST', () => { }, }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); - ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv, templateSrv, timeSrv); + ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); await ctx.ds.query(query).then(function(data) { results = data; }); diff --git a/public/app/plugins/panel/graph/specs/graph.test.ts b/public/app/plugins/panel/graph/specs/graph.test.ts index 64dd1de01ed..037a02a5bf0 100644 --- a/public/app/plugins/panel/graph/specs/graph.test.ts +++ b/public/app/plugins/panel/graph/specs/graph.test.ts @@ -28,7 +28,7 @@ import moment from 'moment'; import $ from 'jquery'; import { graphDirective } from '../graph'; -const ctx = {}; +const ctx = {} as any; let ctrl; const scope = { ctrl: {}, @@ -47,7 +47,7 @@ describe('grafanaGraph', function() { lightTheme: false, }, }; - GraphCtrl.prototype = { + GraphCtrl.prototype = { ...MetricsPanelCtrl.prototype, ...PanelCtrl.prototype, ...GraphCtrl.prototype, @@ -88,7 +88,7 @@ describe('grafanaGraph', function() { from: moment([2015, 1, 1, 10]), to: moment([2015, 1, 1, 22]), }, - }; + } as any; ctx.data = []; ctx.data.push( diff --git a/public/app/plugins/panel/graph/specs/graph_ctrl.test.ts b/public/app/plugins/panel/graph/specs/graph_ctrl.test.ts index 2feb94a5626..826b71f429e 100644 --- a/public/app/plugins/panel/graph/specs/graph_ctrl.test.ts +++ b/public/app/plugins/panel/graph/specs/graph_ctrl.test.ts @@ -30,7 +30,7 @@ describe('GraphCtrl', () => { }, }; - const ctx = {}; + const ctx = {} as any; beforeEach(() => { ctx.ctrl = new GraphCtrl(scope, injector, {}); diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts index 8e1623c7d6f..740d4045013 100644 --- a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts +++ b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts @@ -2,7 +2,7 @@ import moment from 'moment'; import { HeatmapCtrl } from '../heatmap_ctrl'; describe('HeatmapCtrl', function() { - const ctx = {}; + const ctx = {} as any; const $injector = { get: () => {}, diff --git a/public/app/plugins/panel/singlestat/specs/singlestat.test.ts b/public/app/plugins/panel/singlestat/specs/singlestat.test.ts index 9d204f19f5b..bacc972c058 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat.test.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat.test.ts @@ -2,7 +2,7 @@ import { SingleStatCtrl } from '../module'; import moment from 'moment'; describe('SingleStatCtrl', function() { - const ctx = {}; + const ctx = {} as any; const epoch = 1505826363746; Date.now = () => epoch; diff --git a/public/test/index.ts b/public/test/index.ts index 05a47686775..798d8b57de7 100644 --- a/public/test/index.ts +++ b/public/test/index.ts @@ -21,7 +21,7 @@ angular.module('grafana.directives', []); angular.module('grafana.filters', []); angular.module('grafana.routes', ['ngRoute']); -const context = (require).context('../', true, /specs\.(tsx?|js)/); +const context = (require as any).context('../', true, /specs\.(tsx?|js)/); for (const key of context.keys()) { context(key); } diff --git a/public/test/jest-setup.ts b/public/test/jest-setup.ts index fed65097ac7..47cbbcb44f6 100644 --- a/public/test/jest-setup.ts +++ b/public/test/jest-setup.ts @@ -18,5 +18,5 @@ jest.mock('app/features/plugins/plugin_loader', () => ({})); configure({ adapter: new Adapter() }); -const global = window; +const global = window as any; global.$ = global.jQuery = $; diff --git a/public/test/jest-shim.ts b/public/test/jest-shim.ts index dbf9ac4be50..98c12642a40 100644 --- a/public/test/jest-shim.ts +++ b/public/test/jest-shim.ts @@ -1,10 +1,10 @@ declare var global: NodeJS.Global; -(global).requestAnimationFrame = callback => { +(global as any).requestAnimationFrame = callback => { setTimeout(callback, 0); }; -(Promise.prototype).finally = function(onFinally) { +(Promise.prototype as any).finally = function(onFinally) { return this.then( /* onFulfilled */ res => Promise.resolve(onFinally()).then(() => res), diff --git a/public/test/lib/common.ts b/public/test/lib/common.ts index ac05f83391c..44463dbeeef 100644 --- a/public/test/lib/common.ts +++ b/public/test/lib/common.ts @@ -1,4 +1,4 @@ -const _global = window; +const _global = window as any; const beforeEach = _global.beforeEach; const afterEach = _global.afterEach; const before = _global.before; diff --git a/tslint.json b/tslint.json index e212d5d5cfa..f143435de3f 100644 --- a/tslint.json +++ b/tslint.json @@ -29,6 +29,7 @@ "label-position": true, "max-line-length": [true, 150], "member-access": [true, "no-public"], + "no-angle-bracket-type-assertion": true, "no-arg": true, "no-bitwise": false, "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],