Chore: type fixes (#77618)

* type fixes

* couple more

* just a couple more

* small fixes to prometheus typings

* improve some more datasource types
This commit is contained in:
Ashley Harrison 2023-11-06 11:28:44 +00:00 committed by GitHub
parent a1718aafce
commit d1e52d4788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 131 additions and 215 deletions

View File

@ -5958,16 +5958,16 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
@ -6009,15 +6009,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "51"],
[0, 0, 0, "Unexpected any. Specify a different type.", "52"],
[0, 0, 0, "Unexpected any. Specify a different type.", "53"],
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Unexpected any. Specify a different type.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Unexpected any. Specify a different type.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"]
[0, 0, 0, "Unexpected any. Specify a different type.", "54"]
],
"public/app/plugins/datasource/graphite/gfunc.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6030,11 +6022,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
[0, 0, 0, "Unexpected any. Specify a different type.", "10"]
],
"public/app/plugins/datasource/graphite/graphite_query.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6052,15 +6040,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Do not use any type assertions.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"]
[0, 0, 0, "Unexpected any. Specify a different type.", "19"]
],
"public/app/plugins/datasource/graphite/lexer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6074,11 +6058,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/graphite/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/graphite/parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/graphite/specs/graphite_query.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -6095,17 +6074,14 @@ exports[`better eslint`] = {
],
"public/app/plugins/datasource/graphite/state/store.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/graphite/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/graphite/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/influxdb/components/editor/config/ConfigEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
@ -6138,9 +6114,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"]
[0, 0, 0, "Do not use any type assertions.", "15"]
],
"public/app/plugins/datasource/influxdb/influx_query_model.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6155,14 +6129,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"]
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
],
"public/app/plugins/datasource/influxdb/influx_series.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6210,8 +6177,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
[0, 0, 0, "Unexpected any. Specify a different type.", "15"]
],
"public/app/plugins/datasource/influxdb/response_parser.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6232,14 +6198,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/plugins/datasource/jaeger/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/jaeger/testResponse.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6248,13 +6208,9 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/jaeger/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/jaeger/util.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/loki/LanguageProvider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/loki/LiveStreams.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -6364,8 +6320,7 @@ exports[`better eslint`] = {
],
"public/app/plugins/datasource/loki/streaming.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/opentsdb/components/OpenTsdbQueryEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
@ -6458,8 +6413,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/prometheus/components/PromQueryField.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
@ -6473,9 +6427,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "8"],
[0, 0, 0, "Styles should be written using objects.", "9"],
[0, 0, 0, "Styles should be written using objects.", "10"],
[0, 0, 0, "Styles should be written using objects.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Do not use any type assertions.", "13"]
[0, 0, 0, "Styles should be written using objects.", "11"]
],
"public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
@ -6532,9 +6484,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/prometheus/datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6561,7 +6510,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
@ -6569,16 +6518,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"]
[0, 0, 0, "Unexpected any. Specify a different type.", "19"]
],
"public/app/plugins/datasource/prometheus/language_provider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6855,17 +6795,13 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
],
"public/app/plugins/datasource/tempo/language_provider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -7111,9 +7047,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/panel/geomap/utils/selection.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/geomap/utils/tooltip.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@ -7196,11 +7129,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "16"]
],
"public/app/plugins/panel/histogram/Histogram.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/panel/live/LiveChannelEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -7296,9 +7227,7 @@ exports[`better eslint`] = {
],
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/piechart/PieChart.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
@ -7644,20 +7573,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/types/templates.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/types/unified-alerting-dto.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/test/core/redux/mocks.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/core/redux/reducerTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/test/core/redux/reduxTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -7674,15 +7593,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/test/global-jquery-shim.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/helpers/convertToStoreState.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/helpers/getDashboardModel.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -7695,20 +7610,11 @@ exports[`better eslint`] = {
"public/test/lib/common.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/matchers/index.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/matchers/toEmitValuesWith.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/test/matchers/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/mocks/workers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/test/specs/helpers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -7723,9 +7629,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"]
[0, 0, 0, "Unexpected any. Specify a different type.", "13"]
]
}`
};

View File

@ -28,7 +28,7 @@ import { getRollupNotice, getRuntimeConsolidationNotice } from 'app/plugins/data
import { AnnotationEditor } from './components/AnnotationsEditor';
import { convertToGraphiteQueryObject } from './components/helpers';
import gfunc, { FuncDefs, FuncInstance } from './gfunc';
import gfunc, { FuncDef, FuncDefs, FuncInstance } from './gfunc';
import GraphiteQueryModel from './graphite_query';
import { prepareAnnotation } from './migrations';
// Types
@ -78,7 +78,7 @@ export class GraphiteDatasource
cacheTimeout: any;
withCredentials: boolean;
funcDefs: FuncDefs | null = null;
funcDefsPromise: Promise<any> | null = null;
funcDefsPromise: Promise<FuncDefs> | null = null;
_seriesRefLetters: string;
requestCounter = 100;
private readonly metricMappings: GraphiteLokiMapping[];
@ -371,7 +371,7 @@ export class GraphiteDatasource
return lastValueFrom(
this.query(graphiteQuery).pipe(
map((result: any) => {
map((result) => {
const list = [];
for (let i = 0; i < result.data.length; i++) {
@ -400,7 +400,7 @@ export class GraphiteDatasource
} else {
// Graphite event/tag as annotation
const tags = this.templateSrv.replace(target.tags?.join(' '));
return this.events({ range: range, tags: tags }).then((results: any) => {
return this.events({ range: range, tags: tags }).then((results) => {
const list = [];
if (!isArray(results.data)) {
console.error(`Unable to get annotations from ${results.url}.`);
@ -827,7 +827,7 @@ export class GraphiteDatasource
);
}
createFuncInstance(funcDef: any, options?: any): FuncInstance {
createFuncInstance(funcDef: string | FuncDef, options?: any): FuncInstance {
return gfunc.createFuncInstance(funcDef, options, this.funcDefs);
}
@ -870,7 +870,7 @@ export class GraphiteDatasource
this.funcDefs = gfunc.parseFuncDefs(fixedData);
return this.funcDefs;
}),
catchError((error: any) => {
catchError((error) => {
console.error('Fetching graphite functions error', error);
this.funcDefs = gfunc.getFuncDefs(this.graphiteVersion);
return of(this.funcDefs);
@ -924,7 +924,7 @@ export class GraphiteDatasource
return getBackendSrv()
.fetch(options)
.pipe(
catchError((err: any) => {
catchError((err) => {
return throwError(reduceError(err));
})
);
@ -941,7 +941,7 @@ export class GraphiteDatasource
options['format'] = 'json';
function fixIntervalFormat(match: any) {
function fixIntervalFormat(match: string) {
return match.replace('m', 'min').replace('M', 'mon');
}
@ -1007,7 +1007,7 @@ function supportsFunctionIndex(version: string): boolean {
function mapToTags(): OperatorFunction<any, Array<{ text: string }>> {
return pipe(
map((results: any) => {
map((results) => {
if (results.data) {
return _map(results.data, (value) => {
return { text: value };

View File

@ -1061,7 +1061,7 @@ export class FuncInstance {
return str + parameters.join(', ') + ')';
}
_hasMultipleParamsInString(strValue: any, index: number) {
_hasMultipleParamsInString(strValue: string, index: number) {
if (strValue.indexOf(',') === -1) {
return false;
}
@ -1077,7 +1077,7 @@ export class FuncInstance {
return false;
}
updateParam(strValue: any, index: any) {
updateParam(strValue: string, index: number) {
// handle optional parameters
// if string contains ',' and next param is optional, split and update both
if (this._hasMultipleParamsInString(strValue, index)) {
@ -1109,7 +1109,7 @@ export class FuncInstance {
}
}
function createFuncInstance(funcDef: any, options?: { withDefaultParams: any }, idx?: any): FuncInstance {
function createFuncInstance(funcDef: FuncDef | string, options?: { withDefaultParams: any }, idx?: any): FuncInstance {
if (isString(funcDef)) {
funcDef = getFuncDef(funcDef, idx);
}

View File

@ -159,11 +159,11 @@ export default class GraphiteQuery {
this.segments.push({ value: 'select metric' });
}
addFunction(newFunc: any) {
addFunction(newFunc: FuncInstance) {
this.functions.push(newFunc);
}
addFunctionParameter(func: any, value: string) {
addFunctionParameter(func: FuncInstance, value: string) {
if (func.params.length >= func.def.params.length && !get(last(func.def.params), 'multiple', false)) {
throw { message: 'too many parameters for function ' + func.def.name };
}
@ -174,13 +174,13 @@ export default class GraphiteQuery {
this.functions = without(this.functions, func);
}
moveFunction(func: any, offset: number) {
moveFunction(func: FuncInstance, offset: number) {
const index = this.functions.indexOf(func);
arrayMove(this.functions, index, index + offset);
}
updateModelTarget(targets: any) {
const wrapFunction = (target: string, func: any) => {
const wrapFunction = (target: string, func: FuncInstance) => {
return func.render(target, (value: string) => {
return this.templateSrv.replace(value, this.scopedVars);
});

View File

@ -276,12 +276,12 @@ export class Parser {
return this.tokens[this.index - 1];
}
matchToken(type: any, index: number) {
matchToken(type: string, index: number) {
const token = this.tokens[this.index + index];
return (token === undefined && type === '') || (token && token.type === type);
}
match(token1: any, token2?: any) {
match(token1: string, token2?: string) {
return this.matchToken(token1, 0) && (!token2 || this.matchToken(token2, 1));
}
}

View File

@ -8,7 +8,7 @@ import { TemplateSrv } from '../../../../features/templating/template_srv';
import { GraphiteDatasource } from '../datasource';
import { FuncDefs } from '../gfunc';
import GraphiteQuery, { GraphiteTarget } from '../graphite_query';
import { GraphiteSegment, GraphiteTagOperator } from '../types';
import { GraphiteSegment } from '../types';
import { actions } from './actions';
import {
@ -91,7 +91,7 @@ const reducer = async (action: Action, state: GraphiteQueryEditorState): Promise
fake: false,
};
} else {
segment = segmentOrString as GraphiteSegment;
segment = segmentOrString;
}
state.error = null;
@ -131,7 +131,7 @@ const reducer = async (action: Action, state: GraphiteQueryEditorState): Promise
if (actions.addNewTag.match(action)) {
const segment = action.payload.segment;
const newTagKey = segment.value;
const newTag = { key: newTagKey, operator: '=' as GraphiteTagOperator, value: '' };
const newTag = { key: newTagKey, operator: '=' as const, value: '' };
state.queryModel.addTag(newTag);
handleTargetChanged(state);
}

View File

@ -8,7 +8,7 @@ import { GraphiteParserError } from './types';
* This function removes all HTML tags and keeps only the last line from the stack
* trace which should be the most meaningful.
*/
export function reduceError(error: any): any {
export function reduceError(error: any) {
if (error && error.status === 500 && error.data?.message?.startsWith('<body')) {
// Remove all HTML tags and take the last line from the stack trace
const newMessage = last<string>(

View File

@ -590,7 +590,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
allQueries = this.templateSrv.replace(allQueries, scopedVars);
return this._seriesQuery(allQueries, options).pipe(
map((data: any) => {
map((data) => {
if (!data || !data.results) {
return { data: [] };
}
@ -690,7 +690,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
let query = annotation.query.replace('$timeFilter', timeFilter);
query = this.templateSrv.replace(query, undefined, this.interpolateQueryExpr);
return lastValueFrom(this._seriesQuery(query, options)).then((data: any) => {
return lastValueFrom(this._seriesQuery(query, options)).then((data) => {
if (!data || !data.results || !data.results[0]) {
throw { message: 'No results in response from InfluxDB' };
}

View File

@ -39,7 +39,7 @@ export default class InfluxQueryModel {
}
updateProjection() {
this.selectModels = map(this.target.select, (parts: any) => {
this.selectModels = map(this.target.select, (parts) => {
return map(parts, queryPart.create);
});
this.groupByParts = map(this.target.groupBy, queryPart.create);
@ -47,18 +47,18 @@ export default class InfluxQueryModel {
updatePersistedParts() {
this.target.select = map(this.selectModels, (selectParts) => {
return map(selectParts, (part: any) => {
return map(selectParts, (part) => {
return { type: part.def.type, params: part.params };
});
});
}
hasGroupByTime() {
return find(this.target.groupBy, (g: any) => g.type === 'time');
return find(this.target.groupBy, (g) => g.type === 'time');
}
hasFill() {
return find(this.target.groupBy, (g: any) => g.type === 'fill');
return find(this.target.groupBy, (g) => g.type === 'fill');
}
addGroupBy(value: string) {
@ -95,10 +95,10 @@ export default class InfluxQueryModel {
if (part.def.type === 'time') {
// remove fill
this.target.groupBy = filter(this.target.groupBy, (g: any) => g.type !== 'fill');
this.target.groupBy = filter(this.target.groupBy, (g) => g.type !== 'fill');
// remove aggregations
this.target.select = map(this.target.select, (s: any) => {
return filter(s, (part: any) => {
this.target.select = map(this.target.select, (s) => {
return filter(s, (part) => {
const partModel = queryPart.create(part);
if (partModel.def.category === categories.Aggregations) {
return false;

View File

@ -140,7 +140,7 @@ function addAliasStrategy(selectParts: any[], partModel: any) {
function addFieldStrategy(selectParts: any, partModel: any, query: { selectModels: any[][] }) {
// copy all parts
const parts = map(selectParts, (part: any) => {
const parts = map(selectParts, (part) => {
return createPart({ type: part.def.type, params: clone(part.params) });
});

View File

@ -47,7 +47,7 @@ export class JaegerDatasource extends DataSourceApi<JaegerQuery, JaegerJsonData>
this.traceIdTimeParams = instanceSettings.jsonData.traceIdTimeParams;
}
async metadataRequest(url: string, params?: Record<string, any>): Promise<any> {
async metadataRequest(url: string, params?: Record<string, unknown>) {
const res = await lastValueFrom(this._request(url, params, { hideFromInspector: true }));
return res.data.data;
}
@ -180,11 +180,11 @@ export class JaegerDatasource extends DataSourceApi<JaegerQuery, JaegerJsonData>
};
}
async testDatasource(): Promise<any> {
async testDatasource() {
return lastValueFrom(
this._request('/api/services').pipe(
map((res) => {
const values: any[] = res?.data?.data || [];
const values = res?.data?.data || [];
const testResult =
values.length > 0
? { status: 'success', message: 'Data source connected and services found.' }
@ -195,7 +195,7 @@ export class JaegerDatasource extends DataSourceApi<JaegerQuery, JaegerJsonData>
};
return testResult;
}),
catchError((err: any) => {
catchError((err) => {
let message = 'Jaeger: ';
if (err.statusText) {
message += err.statusText;
@ -230,7 +230,11 @@ export class JaegerDatasource extends DataSourceApi<JaegerQuery, JaegerJsonData>
return query.query || '';
}
private _request(apiUrl: string, data?: any, options?: Partial<BackendSrvRequest>): Observable<Record<string, any>> {
private _request(
apiUrl: string,
data?: Record<string, unknown>,
options?: Partial<BackendSrvRequest>
): Observable<Record<string, any>> {
const params = data ? serializeParams(data) : '';
const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`;
const req = {

View File

@ -4,7 +4,7 @@ export function convertTagsLogfmt(tags: string | undefined) {
if (!tags) {
return '';
}
const data: any = logfmt.parse(tags);
const data = logfmt.parse(tags);
Object.keys(data).forEach((key) => {
const value = data[key];
if (typeof value !== 'string') {

View File

@ -37,7 +37,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
Object.assign(this, initialValues);
}
request = async (url: string, params?: any): Promise<any> => {
request = async (url: string, params?: any) => {
try {
return await this.datasource.metadataRequest(url, params);
} catch (error) {

View File

@ -45,7 +45,7 @@ export function doLokiChannelStream(
let frame: StreamingDataFrame | undefined = undefined;
const updateFrame = (msg: any) => {
if (msg?.message) {
const p = msg.message as DataFrameJSON;
const p: DataFrameJSON = msg.message;
if (!frame) {
frame = StreamingDataFrame.fromDataFrameJSON(p, {
maxLength,

View File

@ -50,8 +50,8 @@ interface PromQueryFieldState {
class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryFieldState> {
declare languageProviderInitializationPromise: CancelablePromise<any>;
constructor(props: PromQueryFieldProps, context: React.Context<any>) {
super(props, context);
constructor(props: PromQueryFieldProps) {
super(props);
this.state = {
labelBrowserVisible: false,

View File

@ -500,7 +500,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
height={Math.min(450, metricCount * LIST_ITEM_SIZE)}
itemCount={metricCount}
itemSize={LIST_ITEM_SIZE}
itemKey={(i) => (metrics!.values as FacettableValue[])[i].name}
itemKey={(i) => metrics!.values![i].name}
width={300}
className={styles.valueList}
>
@ -589,7 +589,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
height={Math.min(200, LIST_ITEM_SIZE * (label.values?.length || 0))}
itemCount={label.values?.length || 0}
itemSize={28}
itemKey={(i) => (label.values as FacettableValue[])[i].name}
itemKey={(i) => label.values![i].name}
width={200}
className={styles.valueList}
>

View File

@ -549,11 +549,11 @@ export const getValueFromEventItem = (eventItem: SyntheticEvent<HTMLInputElement
return '';
}
if (eventItem.hasOwnProperty('currentTarget')) {
if ('currentTarget' in eventItem) {
return eventItem.currentTarget.value;
}
return (eventItem as SelectableValue<string>).value;
return eventItem.value;
};
const onChangeHandler =

View File

@ -227,7 +227,7 @@ export class PrometheusDatasource
* request. Any processing done here needs to be also copied on the backend as this goes through data source proxy
* but not through the same code as alerting.
*/
_request<T = any>(
_request<T = unknown>(
url: string,
data: Record<string, string> | null,
overrides: Partial<BackendSrvRequest> = {}
@ -369,7 +369,7 @@ export class PrometheusDatasource
delete instantTarget.maxDataPoints;
// Create range target
const rangeTarget: any = cloneDeep(target);
const rangeTarget = cloneDeep(target);
rangeTarget.format = 'time_series';
rangeTarget.instant = false;
instantTarget.range = true;
@ -398,7 +398,7 @@ export class PrometheusDatasource
);
// If running only instant query in Explore, format as table
} else if (target.instant && options.app === CoreApp.Explore) {
const instantTarget: any = cloneDeep(target);
const instantTarget = cloneDeep(target);
instantTarget.format = 'table';
queries.push(this.createQuery(instantTarget, options, start, end));
activeTargets.push(instantTarget);
@ -536,18 +536,19 @@ export class PrometheusDatasource
// (should hold until there is some streaming requests involved).
tap(() => runningQueriesCount--),
filter((response: any) => (response.cancelled ? false : true)),
map((response: any) => {
map((response) => {
const data = transform(response, {
query,
target,
responseListLength: queries.length,
exemplarTraceIdDestinations: this.exemplarTraceIdDestinations,
});
return {
const result: DataQueryResponse = {
data,
key: query.requestId,
state: runningQueriesCount === 0 ? LoadingState.Done : LoadingState.Loading,
} as DataQueryResponse;
};
return result;
})
);
@ -569,7 +570,7 @@ export class PrometheusDatasource
const filterAndMapResponse = pipe(
filter((response: any) => (response.cancelled ? false : true)),
map((response: any) => {
map((response) => {
const data = transform(response, {
query,
target,
@ -1174,11 +1175,7 @@ export class PrometheusDatasource
}
// Used when running queries through backend
applyTemplateVariables(
target: PromQuery,
scopedVars: ScopedVars,
filters?: AdHocVariableFilter[]
): Record<string, any> {
applyTemplateVariables(target: PromQuery, scopedVars: ScopedVars, filters?: AdHocVariableFilter[]) {
const variables = cloneDeep(scopedVars);
// We want to interpolate these variables on backend
@ -1302,10 +1299,10 @@ export function extractRuleMappingFromGroups(groups: any[]) {
// NOTE: these two functions are very similar to the escapeLabelValueIn* functions
// in language_utils.ts, but they are not exactly the same algorithm, and we found
// no way to reuse one in the another or vice versa.
export function prometheusRegularEscape(value: any) {
export function prometheusRegularEscape(value: unknown) {
return typeof value === 'string' ? value.replace(/\\/g, '\\\\').replace(/'/g, "\\\\'") : value;
}
export function prometheusSpecialRegexEscape(value: any) {
export function prometheusSpecialRegexEscape(value: unknown) {
return typeof value === 'string' ? value.replace(/\\/g, '\\\\\\\\').replace(/[$^*{}\[\]\'+?.()|]/g, '\\\\$&') : value;
}

View File

@ -18,6 +18,7 @@ import {
LoadingState,
rangeUtil,
ScopedVars,
TestDataSourceResponse,
} from '@grafana/data';
import {
BackendSrvRequest,
@ -496,7 +497,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
return merge(...subQueries);
}
applyTemplateVariables(query: TempoQuery, scopedVars: ScopedVars): Record<string, any> {
applyTemplateVariables(query: TempoQuery, scopedVars: ScopedVars) {
return this.applyVariables(query, scopedVars);
}
@ -685,7 +686,11 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
return await lastValueFrom(this._request(url, params, { method: 'GET', hideFromInspector: true }));
}
private _request(apiUrl: string, data?: any, options?: Partial<BackendSrvRequest>): Observable<Record<string, any>> {
private _request(
apiUrl: string,
data?: unknown,
options?: Partial<BackendSrvRequest>
): Observable<Record<string, any>> {
const params = data ? serializeParams(data) : '';
const url = `${this.instanceSettings.url}${apiUrl}${params.length ? `?${params}` : ''}`;
const req = { ...options, url };
@ -693,7 +698,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
return getBackendSrv().fetch(req);
}
async testDatasource(): Promise<any> {
async testDatasource(): Promise<TestDataSourceResponse> {
const options: BackendSrvRequest = {
headers: {},
method: 'GET',
@ -1297,7 +1302,7 @@ export function getRateAlignedValues(
return values;
}
export function makeServiceGraphViewRequest(metrics: any[]) {
export function makeServiceGraphViewRequest(metrics: string[]): PromQuery[] {
return metrics.map((metric) => {
return {
refId: metric,

View File

@ -1,6 +1,6 @@
import { SelectableValue } from '@grafana/data';
export interface SelectionInfo<T = any> {
export interface SelectionInfo<T> {
options: Array<SelectableValue<T>>;
current?: SelectableValue<T>;
}

View File

@ -157,8 +157,8 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => {
incrs: isOrdinalX ? [1] : useLogScale ? undefined : histogramBucketSizes,
splits: useLogScale || isOrdinalX ? undefined : xSplits,
values: isOrdinalX
? (u: uPlot, splits: any[]) => splits
: (u: uPlot, splits: any[]) => {
? (u, splits) => splits
: (u, splits) => {
const tickLabels = splits.map(xAxisFormatter);
const maxWidth = tickLabels.reduce(

View File

@ -251,8 +251,8 @@ function computableField(field?: Field) {
* @param edgeFields
*/
function normalizeStatsForNodes(nodesMap: { [id: string]: NodeDatumFromEdge }, edgeFields: EdgeFields): NodeDatum[] {
const secondaryStatValues: any[] = [];
const mainStatValues: any[] = [];
const secondaryStatValues: Array<number | undefined> = [];
const mainStatValues: Array<number | undefined> = [];
const secondaryStatField = computableField(edgeFields.secondaryStat)
? {
...edgeFields.secondaryStat!,

View File

@ -1,5 +1,5 @@
export interface Variable {
name: string;
type: string;
current: any;
current: unknown;
}

View File

@ -1,6 +1,6 @@
import { ActionCreatorWithoutPayload, PayloadActionCreator } from '@reduxjs/toolkit';
export const mockToolkitActionCreator = <T extends string>(creator: PayloadActionCreator<any, T>) => {
export const mockToolkitActionCreator = <P = void, T extends string = string>(creator: PayloadActionCreator<P, T>) => {
return Object.assign(jest.fn(), creator);
};

View File

@ -2,7 +2,9 @@ import { AnyAction } from '@reduxjs/toolkit';
import { cloneDeep } from 'lodash';
import { Action } from 'redux';
type GrafanaReducer<S = any, A extends Action = AnyAction> = (state: S, action: A) => S;
import { StoreState } from 'app/types';
type GrafanaReducer<S = StoreState, A extends Action = AnyAction> = (state: S, action: A) => S;
export interface Given<State> {
givenReducer: (
@ -23,10 +25,6 @@ export interface Then<State> {
whenActionIsDispatched: (action: AnyAction) => Then<State>;
}
interface ObjectType extends Object {
[key: string]: any;
}
export const deepFreeze = <T>(obj: T): T => {
Object.freeze(obj);
@ -37,7 +35,7 @@ export const deepFreeze = <T>(obj: T): T => {
const hasOwnProp = Object.prototype.hasOwnProperty;
if (obj && obj instanceof Object) {
const object: ObjectType = obj;
const object: Record<string, unknown> = obj;
Object.getOwnPropertyNames(object).forEach((propertyName) => {
const objectProperty = object[propertyName];
if (

View File

@ -1,4 +1,3 @@
// @ts-ignore
import { PayloadAction } from '@reduxjs/toolkit';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
@ -13,7 +12,7 @@ export interface ThunkWhen {
whenThunkIsDispatched: (...args: any) => Promise<Array<PayloadAction<any>>>;
}
export const thunkTester = (initialState: any, debug?: boolean): ThunkGiven => {
export const thunkTester = (initialState: unknown, debug?: boolean): ThunkGiven => {
const store = mockStore(initialState);
let thunkUnderTest: any = null;
let dispatchedActions: Array<PayloadAction<any>> = [];

View File

@ -1,8 +1,11 @@
import { TypedVariableModel } from '@grafana/data';
import { getPreloadedState } from '../../app/features/variables/state/helpers';
import { VariablesState } from '../../app/features/variables/state/types';
import { StoreState } from '../../app/types';
export const convertToStoreState = (key: string, models: any[]): StoreState => {
const variables = models.reduce((byName, variable) => {
export const convertToStoreState = (key: string, models: TypedVariableModel[]): StoreState => {
const variables = models.reduce<VariablesState>((byName, variable) => {
byName[variable.name] = variable;
return byName;
}, {});

View File

@ -4,7 +4,7 @@ import { toEmitValues } from './toEmitValues';
import { toEmitValuesWith } from './toEmitValuesWith';
import { ObservableMatchers } from './types';
export const matchers: ObservableMatchers<void, Observable<any>> = {
export const matchers: ObservableMatchers<void, Observable<unknown>> = {
toEmitValues,
toEmitValuesWith,
};

View File

@ -3,7 +3,10 @@ import { asapScheduler, Subscription, timer, isObservable } from 'rxjs';
import { OBSERVABLE_TEST_TIMEOUT_IN_MS } from './types';
export function forceObservableCompletion(subscription: Subscription, resolve: (args: any) => void) {
export function forceObservableCompletion(
subscription: Subscription,
resolve: (args: jest.CustomMatcherResult | PromiseLike<jest.CustomMatcherResult>) => void
) {
const timeoutObservable = timer(OBSERVABLE_TEST_TIMEOUT_IN_MS, asapScheduler);
subscription.add(

View File

@ -1,9 +1,12 @@
import { Config } from 'app/plugins/panel/nodeGraph/layout';
import { EdgeDatum, NodeDatum } from 'app/plugins/panel/nodeGraph/types';
const { layout } = jest.requireActual('../../app/plugins/panel/nodeGraph/layout.worker.js');
class LayoutMockWorker {
timeout: number | undefined;
constructor() {}
postMessage(data: any) {
postMessage(data: { nodes: NodeDatum[]; edges: EdgeDatum[]; config: Config }) {
const { nodes, edges, config } = data;
this.timeout = window.setTimeout(() => {
this.timeout = undefined;

View File

@ -129,7 +129,7 @@ export class TimeSrvStub {
};
}
setTime(time: any) {
setTime(time: RawTimeRange) {
this.time = time;
}
}
@ -161,7 +161,7 @@ export function TemplateSrvStub(this: any) {
return template(text, this.templateSettings)(this.data);
};
this.init = () => {};
this.getAdhocFilters = (): any => {
this.getAdhocFilters = () => {
return [];
};
this.fillVariableValuesForUrl = () => {};