From 641031cfaf3adba63683ee65cc66167832977f62 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Mon, 7 Apr 2025 11:29:30 +0100 Subject: [PATCH] Chore: Type fixes (#103340) * tidy tidy * more fixes * some TableNG fixes * another TableNG test fix * some more fixes * betterer... --- .betterer.results | 165 ++---------------- .../SingleStatShared/SingleStatBaseOptions.ts | 11 +- .../StatsPicker/StatsPicker.story.tsx | 23 +-- .../Table/TableNG/Cells/HeaderCell.tsx | 4 +- .../components/Table/TableNG/TableNG.test.tsx | 14 +- .../src/components/Table/TableNG/TableNG.tsx | 17 +- .../components/Table/TableNG/utils.test.ts | 10 +- .../grafana-ui/src/themes/stylesFactory.ts | 4 +- packages/grafana-ui/src/types/jquery.d.ts | 9 - packages/grafana-ui/src/types/mdx.d.ts | 4 - packages/grafana-ui/src/utils/dom.ts | 10 +- public/app/features/explore/Logs/Logs.tsx | 2 +- .../features/explore/Logs/LogsContainer.tsx | 16 +- .../manage-dashboards/state/actions.ts | 2 +- public/app/features/org/state/actions.ts | 6 +- .../app/features/panel/panellinks/link_srv.ts | 2 +- public/app/features/plugins/datasource_srv.ts | 15 +- .../DashboardQueryRunner.ts | 2 +- .../query/state/updateQueries.test.ts | 12 +- public/app/features/search/service/sql.ts | 6 +- public/app/features/search/service/types.ts | 10 ++ public/app/features/teams/TeamGroupSync.tsx | 8 +- .../ValueMatchers/NoopMatcherEditor.tsx | 5 +- .../ValueMatchers/RangeMatcherEditor.tsx | 2 +- .../extractFields/extractFields.ts | 10 +- .../lookupGazetteer/fieldLookup.ts | 2 +- .../prepareTimeSeries.test.ts | 2 +- .../prepareTimeSeries/prepareTimeSeries.ts | 4 +- .../adhoc/picker/AdHocFilterRenderer.tsx | 1 - .../features/variables/datasource/actions.ts | 2 +- .../variables/editor/VariableEditorEditor.tsx | 2 +- .../app/features/variables/editor/reducer.ts | 2 +- public/app/features/variables/editor/types.ts | 2 +- public/app/features/variables/guard.ts | 3 +- .../variables/inspect/NetworkGraph.tsx | 4 +- .../app/features/variables/inspect/utils.ts | 4 +- .../app/features/variables/query/actions.ts | 4 +- .../app/features/variables/query/operators.ts | 2 +- .../variables/query/queryRunners.test.ts | 5 +- .../variables/query/variableQueryObserver.ts | 4 +- public/app/features/variables/state/types.ts | 2 +- public/app/features/variables/utils.ts | 9 +- .../datasource/alertmanager/DataSource.ts | 2 +- public/app/types/jquery/jquery.d.ts | 1 - 44 files changed, 149 insertions(+), 277 deletions(-) delete mode 100644 packages/grafana-ui/src/types/mdx.d.ts diff --git a/.betterer.results b/.betterer.results index 8a212543f0e..2246730eb2c 100644 --- a/.betterer.results +++ b/.betterer.results @@ -618,8 +618,8 @@ exports[`better eslint`] = { [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.", "4"], + [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"], @@ -630,16 +630,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.", "17"], - [0, 0, 0, "Unexpected any. Specify a different type.", "18"], - [0, 0, 0, "Unexpected any. Specify a different type.", "19"] - ], - "packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.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.", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "15"] ], "packages/grafana-ui/src/components/Table/Cells/TableCell.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -650,10 +641,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Table/TableCellInspector.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"] - ], "packages/grafana-ui/src/components/Table/TableNG/Filter/Filter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -669,30 +656,13 @@ exports[`better eslint`] = { ], "packages/grafana-ui/src/components/Table/TableNG/TableNG.test.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.", "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, "Unexpected any. Specify a different type.", "8"] - ], - "packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx: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, "Unexpected any. Specify a different type.", "1"] ], "packages/grafana-ui/src/components/Table/TableNG/utils.test.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.", "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.", "3"] ], "packages/grafana-ui/src/components/Table/TableNG/utils.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -800,8 +770,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"] ], "packages/grafana-ui/src/themes/stylesFactory.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"] ], "packages/grafana-ui/src/types/forms.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -809,16 +778,7 @@ exports[`better eslint`] = { "packages/grafana-ui/src/types/jquery.d.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.", "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"] - ], - "packages/grafana-ui/src/types/mdx.d.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] + [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "packages/grafana-ui/src/types/react-table-config.d.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -828,9 +788,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "packages/grafana-ui/src/utils/dom.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.", "0"] ], "packages/grafana-ui/src/utils/useAsyncDependency.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] @@ -2378,8 +2336,7 @@ exports[`better eslint`] = { ], "public/app/features/explore/Logs/Logs.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] ], "public/app/features/explore/Logs/LogsColumnSearch.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] @@ -2735,8 +2692,7 @@ 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/app/features/manage-dashboards/state/reducers.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2770,9 +2726,6 @@ exports[`better eslint`] = { "public/app/features/org/UserInvitePage.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"] ], - "public/app/features/org/state/actions.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/org/state/reducers.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -2791,9 +2744,6 @@ exports[`better eslint`] = { "public/app/features/panel/panellinks/linkSuppliers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/panel/panellinks/link_srv.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/playlist/PlaylistForm.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] @@ -2887,10 +2837,7 @@ exports[`better eslint`] = { [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, "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.", "3"] ], "public/app/features/plugins/extensions/usePluginComponents.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] @@ -2969,9 +2916,6 @@ exports[`better eslint`] = { "public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -2996,13 +2940,7 @@ exports[`better eslint`] = { "public/app/features/query/state/updateQueries.test.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.", "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.", "2"] ], "public/app/features/search/page/components/ActionRow.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"] @@ -3014,9 +2952,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/features/search/service/sql.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/search/service/unified.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -3078,9 +3013,7 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "2"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "3"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "4"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + [0, 0, 0, "No untranslated strings. Wrap text with ", "5"] ], "public/app/features/teams/TeamList.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"], @@ -3162,12 +3095,6 @@ exports[`better eslint`] = { "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/BasicMatcherEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/transformers/FilterByValueTransformer/ValueMatchers/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3281,10 +3208,6 @@ exports[`better eslint`] = { "public/app/features/transformers/extractFields/components/JSONPathEditor.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"] ], - "public/app/features/transformers/extractFields/extractFields.ts:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/transformers/extractFields/fieldExtractors.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3314,9 +3237,6 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "2"] ], - "public/app/features/transformers/lookupGazetteer/fieldLookup.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/transformers/partitionByValues/PartitionByValuesEditor.tsx:5381": [ [0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "1"], @@ -3328,13 +3248,6 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] ], - "public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/transformers/regression/regressionEditor.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] ], @@ -3367,26 +3280,19 @@ exports[`better eslint`] = { "public/app/features/variables/adhoc/picker/AdHocFilterKey.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] ], - "public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/constant/reducer.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], "public/app/features/variables/custom/reducer.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/variables/datasource/actions.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/editor/VariableEditorContainer.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], "public/app/features/variables/editor/VariableEditorEditor.tsx:5381": [ [0, 0, 0, "\'HorizontalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"], - [0, 0, 0, "No untranslated strings. Wrap text with ", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] + [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] ], "public/app/features/variables/editor/VariableEditorList.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], @@ -3402,24 +3308,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/variables/editor/reducer.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/variables/editor/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/variables/guard.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/variables/inspect/NetworkGraph.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.", "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.", "4"] ], "public/app/features/variables/inspect/VariableUsagesButton.tsx:5381": [ [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "0"] @@ -3438,9 +3332,7 @@ exports[`better eslint`] = { [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.", "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.", "5"] ], "public/app/features/variables/pickers/OptionsPicker/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3471,14 +3363,9 @@ 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, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/features/variables/query/operators.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "public/app/features/variables/query/queryRunners.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/variables/query/queryRunners.ts:5381": [ @@ -3489,10 +3376,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/variables/query/variableQueryObserver.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "public/app/features/variables/shared/formatVariable.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -3522,9 +3405,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/app/features/variables/state/types.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/state/upgradeLegacyQueries.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -3552,18 +3432,12 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "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.", "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.", "3"] ], "public/app/features/visualization/data-hover/DataHoverRows.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], [0, 0, 0, "No untranslated strings. Wrap text with ", "1"] ], - "public/app/plugins/datasource/alertmanager/DataSource.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/plugins/datasource/alertmanager/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -4479,8 +4353,7 @@ 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/app/types/store.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], diff --git a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts index 37f4fe00e04..6fd95b77fed 100644 --- a/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts +++ b/packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts @@ -117,12 +117,12 @@ function migrateFromGraphPanel(panel: PanelModel> function migrateFromAngularSinglestat(panel: PanelModel> | any, prevOptions: any) { const prevPanel = prevOptions.angular; const reducer = fieldReducers.getIfExists(prevPanel.valueName); - const options = { + const options: SingleStatBaseOptions = { reduceOptions: { calcs: [reducer ? reducer.id : ReducerID.mean], }, orientation: VizOrientation.Horizontal, - } as any; + }; const defaults: FieldConfig = {}; @@ -188,7 +188,12 @@ function migrateFromAngularSinglestat(panel: PanelModel): SingleStatBaseOptions { if (!panel.options) { // This happens on the first load or when migrating from angular - return {} as any; + return { + reduceOptions: { + calcs: [ReducerID.mean], + }, + orientation: VizOrientation.Horizontal, + }; } const previousVersion = parseFloat(panel.pluginVersion || '6.1'); diff --git a/packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx b/packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx index ef6c373ccb7..f586fa350c2 100644 --- a/packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx +++ b/packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx @@ -2,35 +2,20 @@ import { action } from '@storybook/addon-actions'; import { Meta, StoryFn } from '@storybook/react'; import { PureComponent } from 'react'; -import { StatsPicker } from './StatsPicker'; +import { Props, StatsPicker } from './StatsPicker'; interface State { stats: string[]; } -class WrapperWithState extends PureComponent { - constructor(props: any) { +class WrapperWithState extends PureComponent { + constructor(props: Props) { super(props); this.state = { - stats: this.toStatsArray(props.initialReducers), + stats: [], }; } - toStatsArray = (txt: string): string[] => { - if (!txt) { - return []; - } - return txt.split(',').map((v) => v.trim()); - }; - - componentDidUpdate(prevProps: any) { - const { initialReducers } = this.props; - if (initialReducers !== prevProps.initialReducers) { - console.log('Changing initial reducers'); - this.setState({ stats: this.toStatsArray(initialReducers) }); - } - } - render() { const { placeholder, allowMultiple, menuPlacement, width } = this.props; const { stats } = this.state; diff --git a/packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx b/packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx index 54164d63245..462baacf508 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx @@ -62,7 +62,7 @@ const HeaderCell: React.FC = ({ const handleSort = (event: React.MouseEvent) => { const isMultiSort = event.shiftKey; - onSort(column.key as string, direction === 'ASC' ? 'DESC' : 'ASC', isMultiSort); + onSort(column.key, direction === 'ASC' ? 'DESC' : 'ASC', isMultiSort); }; // collecting header cell refs to handle manual column resize @@ -82,7 +82,7 @@ const HeaderCell: React.FC = ({ if (lastElement) { const handleMouseUp = () => { let newWidth = headerCellParent.clientWidth; - onColumnResize?.(column.key as string, newWidth); + onColumnResize?.(column.key, newWidth); }; lastElement.addEventListener('click', handleMouseUp); diff --git a/packages/grafana-ui/src/components/Table/TableNG/TableNG.test.tsx b/packages/grafana-ui/src/components/Table/TableNG/TableNG.test.tsx index 4db9e07a6e4..13878bb4883 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/TableNG.test.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/TableNG.test.tsx @@ -27,7 +27,7 @@ const createBasicDataFrame = (): DataFrame => { }, }, // Add display function - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: 0, color: undefined, @@ -52,7 +52,7 @@ const createBasicDataFrame = (): DataFrame => { }, }, // Add display function - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), color: undefined, @@ -179,7 +179,7 @@ const createSortingTestDataFrame = (): DataFrame => { }, }, }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: 0, color: undefined, @@ -202,7 +202,7 @@ const createSortingTestDataFrame = (): DataFrame => { }, }, }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), color: undefined, @@ -225,7 +225,7 @@ const createSortingTestDataFrame = (): DataFrame => { }, }, }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: 0, color: undefined, @@ -1335,7 +1335,7 @@ describe('TableNG', () => { // Add color to the display values const originalDisplay = frame.fields[0].display; const expectedColor = '#ff0000'; // Red color - frame.fields[0].display = (value: any) => { + frame.fields[0].display = (value: unknown) => { const displayValue = originalDisplay ? originalDisplay(value) : { text: String(value), numeric: 0 }; return { ...displayValue, @@ -1372,7 +1372,7 @@ describe('TableNG', () => { // Add color to the display values const originalDisplay = frame.fields[0].display; - frame.fields[0].display = (value: any) => { + frame.fields[0].display = (value: unknown) => { const displayValue = originalDisplay ? originalDisplay(value) : { text: String(value), numeric: 0 }; return { ...displayValue, diff --git a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx index 8dea77e3d1e..2fee3e163b2 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx +++ b/packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx @@ -1,14 +1,7 @@ import 'react-data-grid/lib/styles.css'; import { css } from '@emotion/css'; import { useMemo, useState, useLayoutEffect, useCallback, useRef, useEffect } from 'react'; -import DataGrid, { - RenderCellProps, - RenderRowProps, - Row, - SortColumn, - DataGridHandle, - SortDirection, -} from 'react-data-grid'; +import DataGrid, { RenderCellProps, RenderRowProps, Row, SortColumn, DataGridHandle } from 'react-data-grid'; import { useMeasure } from 'react-use'; import { @@ -90,7 +83,7 @@ export function TableNG(props: TableNGProps) { return { columnKey, - direction: (desc ? 'DESC' : 'ASC') as SortDirection, + direction: desc ? ('DESC' as const) : ('ASC' as const), }; }); return initialSort ?? []; @@ -221,10 +214,10 @@ export function TableNG(props: TableNGProps) { // Create a map of column key to column type const columnTypes = useMemo(() => { - return props.data.fields.reduce((acc, field) => { + return props.data.fields.reduce((acc, field) => { acc[field.name] = field.type; return acc; - }, {} as ColumnTypes); + }, {}); }, [props.data.fields]); const getDisplayedValue = (row: TableRow, key: string) => { @@ -456,7 +449,7 @@ export function TableNG(props: TableNGProps) { ); const handleScroll = (event: React.UIEvent) => { - const target = event.target as HTMLDivElement; + const target = event.currentTarget; scrollPositionRef.current = { x: target.scrollLeft, y: target.scrollTop, diff --git a/packages/grafana-ui/src/components/Table/TableNG/utils.test.ts b/packages/grafana-ui/src/components/Table/TableNG/utils.test.ts index de74530a691..5423aab4907 100644 --- a/packages/grafana-ui/src/components/Table/TableNG/utils.test.ts +++ b/packages/grafana-ui/src/components/Table/TableNG/utils.test.ts @@ -64,7 +64,7 @@ const data = createDataFrame({ name: 'Value', type: FieldType.number, values: [], - display: ((v: any) => ({ + display: ((v: unknown) => ({ text: String(v), numeric: v, color: undefined, @@ -777,7 +777,7 @@ describe('TableNG utils', () => { config: {}, values: [1, 22, 333, 4444], // No state property initially - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), }), @@ -821,7 +821,7 @@ describe('TableNG utils', () => { text: '1', }, }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), }), @@ -863,7 +863,7 @@ describe('TableNG utils', () => { text: '4444', }, }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), }), @@ -908,7 +908,7 @@ describe('TableNG utils', () => { // Or if noValue is a valid property: // noValue: true }, - display: (value: any) => ({ + display: (value: unknown) => ({ text: String(value), numeric: Number(value), }), diff --git a/packages/grafana-ui/src/themes/stylesFactory.ts b/packages/grafana-ui/src/themes/stylesFactory.ts index 8fe69e5cb70..b36bf4b337c 100644 --- a/packages/grafana-ui/src/themes/stylesFactory.ts +++ b/packages/grafana-ui/src/themes/stylesFactory.ts @@ -6,8 +6,6 @@ import memoize from 'micro-memoize'; * Creates memoized version of styles creator * @param stylesCreator function accepting dependencies based on which styles are created */ -export function stylesFactory ReturnType>( - stylesCreator: ResultFn -) { +export function stylesFactory ReturnType>(stylesCreator: ResultFn) { return memoize(stylesCreator); } diff --git a/packages/grafana-ui/src/types/jquery.d.ts b/packages/grafana-ui/src/types/jquery.d.ts index 4a6f60b6029..a2bd265a73e 100644 --- a/packages/grafana-ui/src/types/jquery.d.ts +++ b/packages/grafana-ui/src/types/jquery.d.ts @@ -6,12 +6,3 @@ interface JQueryPlot { interface JQueryStatic { plot: JQueryPlot; } - -interface JQuery { - place_tt: any; - modal: any; - tagsinput: any; - typeahead: any; - accessKey: any; - tooltip: any; -} diff --git a/packages/grafana-ui/src/types/mdx.d.ts b/packages/grafana-ui/src/types/mdx.d.ts deleted file mode 100644 index 8df3b3856a6..00000000000 --- a/packages/grafana-ui/src/types/mdx.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module '*.mdx' { - let MDXComponent: (props: any) => JSX.Element; - export default MDXComponent; -} diff --git a/packages/grafana-ui/src/utils/dom.ts b/packages/grafana-ui/src/utils/dom.ts index 0b5e74fce22..4859efb3f41 100644 --- a/packages/grafana-ui/src/utils/dom.ts +++ b/packages/grafana-ui/src/utils/dom.ts @@ -15,11 +15,13 @@ if (typeof window !== 'undefined' && 'Element' in window && !Element.prototype.c }; } -export function getPreviousCousin(node: any, selector: string) { - let sibling = node.parentElement.previousSibling; +export function getPreviousCousin(node: HTMLElement, selector: string) { + let sibling = node.parentElement?.previousSibling; let el; while (sibling) { - el = sibling.querySelector(selector); + if (sibling instanceof HTMLElement) { + el = sibling.querySelector(selector); + } if (el) { return el; } @@ -28,7 +30,7 @@ export function getPreviousCousin(node: any, selector: string) { return undefined; } -export function getNextCharacter(global?: any) { +export function getNextCharacter(global?: typeof globalThis) { const selection = (global || window).getSelection(); if (!selection || !selection.anchorNode) { return null; diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index 42922f57cb8..783f08b8a5f 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -110,7 +110,7 @@ interface Props extends Themeable2 { onClickFilterOutLabel?: (key: string, value: string, frame?: DataFrame) => void; onStartScanning?: () => void; onStopScanning?: () => void; - getRowContext?: (row: LogRowModel, origRow: LogRowModel, options: LogRowContextOptions) => Promise; + getRowContext?: (row: LogRowModel, origRow: LogRowModel, options: LogRowContextOptions) => Promise; getRowContextQuery?: ( row: LogRowModel, options?: LogRowContextOptions, diff --git a/public/app/features/explore/Logs/LogsContainer.tsx b/public/app/features/explore/Logs/LogsContainer.tsx index 51ddbab1635..22daca32de3 100644 --- a/public/app/features/explore/Logs/LogsContainer.tsx +++ b/public/app/features/explore/Logs/LogsContainer.tsx @@ -164,20 +164,28 @@ class LogsContainer extends PureComponent => { + ): Promise => { const { logsQueries } = this.props; if (!origRow.dataFrame.refId || !this.state.dsInstances[origRow.dataFrame.refId]) { - return Promise.resolve([]); + return Promise.resolve({ + data: [], + }); } const ds = this.state.dsInstances[origRow.dataFrame.refId]; if (!hasLogsContextSupport(ds)) { - return Promise.resolve([]); + return Promise.resolve({ + data: [], + }); } const query = this.getQuery(logsQueries, origRow, ds); - return query ? ds.getLogRowContext(row, options, query) : Promise.resolve([]); + return query + ? ds.getLogRowContext(row, options, query) + : Promise.resolve({ + data: [], + }); }; getLogRowContextQuery = async ( diff --git a/public/app/features/manage-dashboards/state/actions.ts b/public/app/features/manage-dashboards/state/actions.ts index adab7a4746c..48a8462a7f9 100644 --- a/public/app/features/manage-dashboards/state/actions.ts +++ b/public/app/features/manage-dashboards/state/actions.ts @@ -268,7 +268,7 @@ export function createFolder(payload: any) { export const SLICE_FOLDER_RESULTS_TO = 1000; export async function searchFolders( - query: any, + query: string, permission?: PermissionLevelString, type: SearchQueryType = SearchQueryType.Folder ): Promise { diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index ee39073640a..af1b46f49b0 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -1,6 +1,6 @@ import { getBackendSrv } from '@grafana/runtime'; import { updateConfigurationSubtitle } from 'app/core/actions'; -import { ThunkResult } from 'app/types'; +import { ThunkResult, UserOrg } from 'app/types'; import { organizationLoaded, userOrganizationsLoaded } from './reducers'; @@ -54,9 +54,9 @@ export function createOrganization( export function getUserOrganizations( dependencies: OrganizationDependencies = { getBackendSrv: getBackendSrv } -): ThunkResult { +): ThunkResult> { return async (dispatch) => { - const result = await dependencies.getBackendSrv().get('/api/user/orgs'); + const result = await dependencies.getBackendSrv().get('/api/user/orgs'); dispatch(userOrganizationsLoaded(result)); return result; diff --git a/public/app/features/panel/panellinks/link_srv.ts b/public/app/features/panel/panellinks/link_srv.ts index 19a7920fc7d..8bd106283c4 100644 --- a/public/app/features/panel/panellinks/link_srv.ts +++ b/public/app/features/panel/panellinks/link_srv.ts @@ -252,7 +252,7 @@ export interface LinkService { export class LinkSrv implements LinkService { getLinkUrl(link: DashboardLink) { - let params: { [key: string]: any } = {}; + let params: { [key: string]: boolean } = {}; if (link.keepTime) { params[`\$${DataLinkBuiltInVars.keepTime}`] = true; diff --git a/public/app/features/plugins/datasource_srv.ts b/public/app/features/plugins/datasource_srv.ts index 76491d3fb05..e145a2e8db0 100644 --- a/public/app/features/plugins/datasource_srv.ts +++ b/public/app/features/plugins/datasource_srv.ts @@ -19,6 +19,7 @@ import { isExpressionReference, } from '@grafana/runtime'; import { ExpressionDatasourceRef } from '@grafana/runtime/internal'; +import { DataQuery, DataSourceJsonData } from '@grafana/schema'; import appEvents from 'app/core/app_events'; import config from 'app/core/config'; import { @@ -60,8 +61,16 @@ export class DatasourceSrv implements DataSourceService { } // Preload expressions - this.datasources[ExpressionDatasourceRef.type] = expressionDatasource as any; - this.datasources[ExpressionDatasourceUID] = expressionDatasource as any; + this.datasources[ExpressionDatasourceRef.type] = expressionDatasource as DataSourceApi< + DataQuery, + DataSourceJsonData, + {} + >; + this.datasources[ExpressionDatasourceUID] = expressionDatasource as DataSourceApi< + DataQuery, + DataSourceJsonData, + {} + >; this.settingsMapByUid[ExpressionDatasourceRef.uid] = expressionInstanceSettings; this.settingsMapByUid[ExpressionDatasourceUID] = expressionInstanceSettings; } @@ -189,7 +198,7 @@ export class DatasourceSrv implements DataSourceService { // Some old plugins does not extend DataSourceApi so we need to manually patch them if (!(instance instanceof DataSourceApi)) { - const anyInstance = instance as any; + const anyInstance: any = instance; anyInstance.name = instanceSettings.name; anyInstance.id = instanceSettings.id; anyInstance.type = instanceSettings.type; diff --git a/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts b/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts index 3c6e8fb25f9..4186ada42e9 100644 --- a/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts +++ b/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts @@ -43,7 +43,7 @@ class DashboardQueryRunnerImpl implements DashboardQueryRunner { this.executeRun = this.executeRun.bind(this); this.results = new ReplaySubject(1); this.runs = new Subject(); - this.cancellationStream = new Subject(); + this.cancellationStream = new Subject(); this.runsSubscription = this.runs.subscribe((options) => this.executeRun(options)); this.eventsSubscription = dashboard.events.subscribe(RefreshEvent, (event) => { this.run({ dashboard: this.dashboard, range: this.timeSrv.timeRange() }); diff --git a/public/app/features/query/state/updateQueries.test.ts b/public/app/features/query/state/updateQueries.test.ts index b1a312f51ed..579a8c59ec2 100644 --- a/public/app/features/query/state/updateQueries.test.ts +++ b/public/app/features/query/state/updateQueries.test.ts @@ -415,10 +415,10 @@ describe('updateQueries with import', () => { ]; const updated = await updateQueries( - newUidDSWithAbstract as any, - (newUidDSWithAbstract as any).uid, + newUidDSWithAbstract as unknown as DataSourceApi, + (newUidDSWithAbstract as unknown as DataSourceApi).uid, queries, - oldUidDSWithAbstract as any + oldUidDSWithAbstract as unknown as DataSourceApi ); expect(exportSpy).toHaveBeenCalledWith(queries); @@ -492,10 +492,10 @@ describe('updateQueries with import', () => { ]; const updated = await updateQueries( - newUidDSWithAbstract as any, - (newUidDSWithAbstract as any).uid, + newUidDSWithAbstract as unknown as DataSourceApi, + (newUidDSWithAbstract as unknown as DataSourceApi).uid, queries, - oldUidDSWithAbstract as any + oldUidDSWithAbstract as unknown as DataSourceApi ); expect(updated.length).toEqual(1); diff --git a/public/app/features/search/service/sql.ts b/public/app/features/search/service/sql.ts index 798f152fd9f..1a169ba568d 100644 --- a/public/app/features/search/service/sql.ts +++ b/public/app/features/search/service/sql.ts @@ -7,7 +7,7 @@ import { PermissionLevelString } from 'app/types'; import { DEFAULT_MAX_VALUES, GENERAL_FOLDER_UID, TYPE_KIND_MAP } from '../constants'; import { DashboardSearchHit, DashboardSearchItemType } from '../types'; -import { DashboardQueryResult, GrafanaSearcher, LocationInfo, QueryResponse, SearchQuery } from './types'; +import { DashboardQueryResult, GrafanaSearcher, LocationInfo, QueryResponse, SearchQuery, SortOptions } from './types'; import { replaceCurrentFolderQuery } from './utils'; interface APIQuery { @@ -132,8 +132,8 @@ export class SQLSearcher implements GrafanaSearcher { // } // ] // } - const opts = await backendSrv.get('/api/search/sorting'); - return opts.sortOptions.map((v: any) => ({ + const opts = await backendSrv.get('/api/search/sorting'); + return opts.sortOptions.map((v) => ({ value: v.name, label: v.displayName, })); diff --git a/public/app/features/search/service/types.ts b/public/app/features/search/service/types.ts index 5f252b98936..cb360ba8deb 100644 --- a/public/app/features/search/service/types.ts +++ b/public/app/features/search/service/types.ts @@ -4,6 +4,16 @@ import { PermissionLevelString } from 'app/types'; import { ManagerKind } from '../../apiserver/types'; +export interface SortOption { + description: string; + displayName: string; + meta: string; + name: string; +} +export interface SortOptions { + sortOptions: SortOption[]; +} + export interface FacetField { field: string; count?: number; diff --git a/public/app/features/teams/TeamGroupSync.tsx b/public/app/features/teams/TeamGroupSync.tsx index 2c01d98e6d5..61e63830fee 100644 --- a/public/app/features/teams/TeamGroupSync.tsx +++ b/public/app/features/teams/TeamGroupSync.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import { PureComponent } from 'react'; +import { FormEventHandler, PureComponent } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { Input, Tooltip, Icon, Button, useTheme2, InlineField, InlineFieldRow } from '@grafana/ui'; @@ -59,11 +59,11 @@ export class TeamGroupSync extends PureComponent { this.setState({ isAdding: !this.state.isAdding }); }; - onNewGroupIdChanged = (event: any) => { - this.setState({ newGroupId: event.target.value }); + onNewGroupIdChanged: FormEventHandler = (event) => { + this.setState({ newGroupId: event.currentTarget.value }); }; - onAddGroup = (event: any) => { + onAddGroup: FormEventHandler = (event) => { event.preventDefault(); this.props.addTeamGroup(this.state.newGroupId); this.setState({ isAdding: false, newGroupId: '' }); diff --git a/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx b/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx index f4458df5baa..670bd81e29b 100644 --- a/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx +++ b/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx @@ -2,11 +2,12 @@ import { ValueMatcherID } from '@grafana/data'; import { ValueMatcherUIRegistryItem } from './types'; -export const NoopMatcherEditor = () => { +interface Props {} +export const NoopMatcherEditor = (props: Props) => { return null; }; -export const getNoopValueMatchersUI = (): Array> => { +export const getNoopValueMatchersUI = (): Array> => { return [ { name: 'Is null', diff --git a/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx b/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx index 36fbc5c07ec..c1e3f0da3fc 100644 --- a/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx +++ b/public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx @@ -12,7 +12,7 @@ import { ValueMatcherEditorConfig, ValueMatcherUIProps, ValueMatcherUIRegistryIt type PropNames = 'from' | 'to'; -export function rangeMatcherEditor( +export function rangeMatcherEditor( config: ValueMatcherEditorConfig ): React.FC>> { return function RangeMatcherEditor({ options, onChange }) { diff --git a/public/app/features/transformers/extractFields/extractFields.ts b/public/app/features/transformers/extractFields/extractFields.ts index 288dea54d78..70ab7f5cfa1 100644 --- a/public/app/features/transformers/extractFields/extractFields.ts +++ b/public/app/features/transformers/extractFields/extractFields.ts @@ -53,7 +53,7 @@ export function addExtractedFields(frame: DataFrame, options: ExtractFieldsOptio const count = frame.length; const names: string[] = []; // keep order - const values = new Map(); + const values = new Map(); const parse = ext.getParser(options); for (let i = 0; i < count; i++) { @@ -99,12 +99,16 @@ export function addExtractedFields(frame: DataFrame, options: ExtractFieldsOptio const fields = names.map((name) => { const buffer = values.get(name); - const field = { + // this should never happen, but let's be safe + if (!buffer) { + throw new Error(`Could not find field with name: ${name}`); + } + const field: Field = { name, values: buffer, type: buffer ? getFieldTypeFromValue(buffer.find((v) => v != null)) : FieldType.other, config: {}, - } as Field; + }; if (config.featureToggles.extractFieldsNameDeduplication) { field.name = getUniqueFieldName(field, frame); } diff --git a/public/app/features/transformers/lookupGazetteer/fieldLookup.ts b/public/app/features/transformers/lookupGazetteer/fieldLookup.ts index 4eb1e576d91..871d06edf05 100644 --- a/public/app/features/transformers/lookupGazetteer/fieldLookup.ts +++ b/public/app/features/transformers/lookupGazetteer/fieldLookup.ts @@ -53,7 +53,7 @@ export function addFieldsFromGazetteer(frames: DataFrame[], gazetteer: Gazetteer if (matcher(field, frame, frames)) { const values = field.values; - const gazetteerFieldValuesBuffer: any[][] = []; + const gazetteerFieldValuesBuffer: unknown[][] = []; for (const gazetteerField of gazetteerFields) { const buffer = new Array(frameLength); diff --git a/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts b/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts index a9def1abca6..7184e16ff91 100644 --- a/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts +++ b/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts @@ -419,7 +419,7 @@ function toEquableDataFrame(source: DataFrame): DataFrame { return toDataFrame({ meta: undefined, ...source, - fields: source.fields.map((field: any) => { + fields: source.fields.map((field) => { return { ...field, config: {}, diff --git a/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts b/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts index 61ec170498f..fc94e308ec7 100644 --- a/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts +++ b/public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts @@ -209,7 +209,7 @@ export function toTimeSeriesLong(data: DataFrame[]): DataFrame[] { } type TimeWideRowIndex = { - time: any; + time: number; wideRowIndex: number; }; const sortedTimeRowIndices: TimeWideRowIndex[] = []; @@ -254,7 +254,7 @@ export function toTimeSeriesLong(data: DataFrame[]): DataFrame[] { const { time, wideRowIndex } = timeWideRowIndex; for (const labelKeys of sortedUniqueLabelKeys) { - const rowValues: Record = {}; + const rowValues: Record = {}; for (const name of uniqueFactorNamesWithWideIndices) { rowValues[name] = frame.fields[uniqueFactorNamesToWideIndex[name]].values[wideRowIndex]; diff --git a/public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx b/public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx index 6c658f5d18a..65b3b7ba3f3 100644 --- a/public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx +++ b/public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx @@ -12,7 +12,6 @@ interface Props { onOperatorChange: (item: SelectableValue) => void; onValueChange: (item: SelectableValue) => void; placeHolder?: string; - getTagKeysOptions?: any; disabled?: boolean; } diff --git a/public/app/features/variables/datasource/actions.ts b/public/app/features/variables/datasource/actions.ts index 00c241d2a5e..d2786309f44 100644 --- a/public/app/features/variables/datasource/actions.ts +++ b/public/app/features/variables/datasource/actions.ts @@ -51,7 +51,7 @@ export const initDataSourceVariableEditor = const dataSources = dependencies.getDatasourceSrv().getList({ metrics: true, variables: true }); const dataSourceTypes = chain(dataSources) .uniqBy('meta.id') - .map((ds: any) => { + .map((ds) => { return { text: ds.meta.name, value: ds.meta.id }; }) .value(); diff --git a/public/app/features/variables/editor/VariableEditorEditor.tsx b/public/app/features/variables/editor/VariableEditorEditor.tsx index 35dde5c70e2..8a53c4bb24e 100644 --- a/public/app/features/variables/editor/VariableEditorEditor.tsx +++ b/public/app/features/variables/editor/VariableEditorEditor.tsx @@ -37,7 +37,7 @@ const mapStateToProps = (state: StoreState, ownProps: OwnProps) => ({ const mapDispatchToProps = (dispatch: ThunkDispatch) => { return { ...bindActionCreators({ variableEditorMount, variableEditorUnMount, changeVariableName, updateOptions }, dispatch), - changeVariableProp: (identifier: KeyedVariableIdentifier, propName: string, propValue: any) => + changeVariableProp: (identifier: KeyedVariableIdentifier, propName: string, propValue: unknown) => dispatch( toKeyedAction( identifier.rootStateKey, diff --git a/public/app/features/variables/editor/reducer.ts b/public/app/features/variables/editor/reducer.ts index e9bc7a1749c..1a6416e473b 100644 --- a/public/app/features/variables/editor/reducer.ts +++ b/public/app/features/variables/editor/reducer.ts @@ -65,7 +65,7 @@ const variableEditorReducerSlice = createSlice({ }, addVariableEditorError: ( state: VariableEditorState, - action: PayloadAction<{ errorProp: string; errorText: any }> + action: PayloadAction<{ errorProp: string; errorText: string }> ) => { state.errors[action.payload.errorProp] = action.payload.errorText; state.isValid = Object.keys(state.errors).length === 0; diff --git a/public/app/features/variables/editor/types.ts b/public/app/features/variables/editor/types.ts index fa86b3111ae..6909d7a5087 100644 --- a/public/app/features/variables/editor/types.ts +++ b/public/app/features/variables/editor/types.ts @@ -6,7 +6,7 @@ export enum VariableNameConstraints { export interface OnPropChangeArguments { propName: keyof Model; - propValue: any; + propValue: unknown; updateOptions?: boolean; } diff --git a/public/app/features/variables/guard.ts b/public/app/features/variables/guard.ts index 97890e05ce2..22092018bfc 100644 --- a/public/app/features/variables/guard.ts +++ b/public/app/features/variables/guard.ts @@ -10,6 +10,7 @@ import { DataSourceApi, DataSourceJsonData, DataSourceRef, + LegacyMetricFindQueryOptions, MetricFindValue, QueryVariableModel, StandardVariableQuery, @@ -61,7 +62,7 @@ interface DataSourceWithLegacyVariableSupport< TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData, > extends DataSourceApi { - metricFindQuery(query: any, options?: any): Promise; + metricFindQuery(query: string, options?: LegacyMetricFindQueryOptions): Promise; variables: undefined; } diff --git a/public/app/features/variables/inspect/NetworkGraph.tsx b/public/app/features/variables/inspect/NetworkGraph.tsx index 46d25fb3266..78b6977359c 100644 --- a/public/app/features/variables/inspect/NetworkGraph.tsx +++ b/public/app/features/variables/inspect/NetworkGraph.tsx @@ -78,7 +78,7 @@ export const NetworkGraph = ({ nodes, edges, direction, width, height, onDoubleC }; function toVisNetworkNodes(visJs: any, nodes: GraphNode[]): any[] { - const nodesWithStyle: any[] = nodes.map((node) => ({ + const nodesWithStyle = nodes.map((node) => ({ ...node, shape: 'box', })); @@ -86,6 +86,6 @@ function toVisNetworkNodes(visJs: any, nodes: GraphNode[]): any[] { } function toVisNetworkEdges(visJs: any, edges: GraphEdge[]): any[] { - const edgesWithStyle: any[] = edges.map((edge) => ({ ...edge, arrows: 'to', dashes: true })); + const edgesWithStyle = edges.map((edge) => ({ ...edge, arrows: 'to', dashes: true })); return new visJs.DataSet(edgesWithStyle); } diff --git a/public/app/features/variables/inspect/utils.ts b/public/app/features/variables/inspect/utils.ts index a8632eca193..ec83bca224e 100644 --- a/public/app/features/variables/inspect/utils.ts +++ b/public/app/features/variables/inspect/utils.ts @@ -125,7 +125,7 @@ const validVariableNames: Record = { }; export const getPropsWithVariable = (variableId: string, parent: { key: string; value: any }, result: any) => { - const stringValues = Object.keys(parent.value).reduce>((all, key) => { + const stringValues = Object.keys(parent.value).reduce>((all, key) => { const value = parent.value[key]; if (!value || typeof value !== 'string') { return all; @@ -151,7 +151,7 @@ export const getPropsWithVariable = (variableId: string, parent: { key: string; return all; }, {}); - const objectValues = Object.keys(parent.value).reduce>((all, key) => { + const objectValues = Object.keys(parent.value).reduce>((all, key) => { const value = parent.value[key]; if (value && typeof value === 'object' && Object.keys(value).length) { let id = value.title || value.name || value.id || key; diff --git a/public/app/features/variables/query/actions.ts b/public/app/features/variables/query/actions.ts index a81391dca21..fe494c17560 100644 --- a/public/app/features/variables/query/actions.ts +++ b/public/app/features/variables/query/actions.ts @@ -55,7 +55,7 @@ export const updateQueryVariableOptions = ( const { rootStateKey } = identifier; if (getVariablesState(rootStateKey, getState()).editor.id === identifier.id) { dispatch( - toKeyedAction(rootStateKey, addVariableEditorError({ errorProp: 'update', errorText: error.message })) + toKeyedAction(rootStateKey, addVariableEditorError({ errorProp: 'update', errorText: error.message ?? '' })) ); } @@ -178,7 +178,7 @@ export function hasSelfReferencingQuery(name: string, query: any): boolean { /* * Function that takes any object and flattens all props into one level deep object * */ -export function flattenQuery(query: any): any { +export function flattenQuery(query: any) { if (typeof query !== 'object' || query === null) { return { query }; } diff --git a/public/app/features/variables/query/operators.ts b/public/app/features/variables/query/operators.ts index ab16fa50ff8..c4bb25960bb 100644 --- a/public/app/features/variables/query/operators.ts +++ b/public/app/features/variables/query/operators.ts @@ -143,7 +143,7 @@ export function validateVariableSelection(args: { ); } -export function areMetricFindValues(data: any[]): data is MetricFindValue[] { +export function areMetricFindValues(data: unknown[]): data is MetricFindValue[] { if (!data) { return false; } diff --git a/public/app/features/variables/query/queryRunners.test.ts b/public/app/features/variables/query/queryRunners.test.ts index 1169f9844ef..e3542b9336a 100644 --- a/public/app/features/variables/query/queryRunners.test.ts +++ b/public/app/features/variables/query/queryRunners.test.ts @@ -5,6 +5,7 @@ import { DataSourceApi, getDefaultTimeRange, QueryVariableModel, + StandardVariableQuery, VariableRefresh, VariableSupportType, } from '@grafana/data'; @@ -166,9 +167,9 @@ describe('QueryRunners', () => { ({ variables: { getType: () => VariableSupportType.Standard, - toDataQuery: (query: any) => ({ ...query, extra: 'extra' }), + toDataQuery: (query: StandardVariableQuery) => ({ ...query, extra: 'extra' }), }, - } as DataSourceApi); + } as unknown as DataSourceApi); const runner = new QueryRunners().getRunnerForDatasource(datasource); const runRequest = jest.fn().mockReturnValue(of({})); const runnerArgs = { diff --git a/public/app/features/variables/query/variableQueryObserver.ts b/public/app/features/variables/query/variableQueryObserver.ts index f6cddbb3059..1511ef0faa4 100644 --- a/public/app/features/variables/query/variableQueryObserver.ts +++ b/public/app/features/variables/query/variableQueryObserver.ts @@ -5,8 +5,8 @@ import { LoadingState } from '@grafana/data'; import { UpdateOptionsResults } from './VariableQueryRunner'; export function variableQueryObserver( - resolve: (value?: any) => void, - reject: (value?: any) => void, + resolve: (value?: unknown) => void, + reject: (value?: unknown) => void, subscription: Subscription ): Observer { const observer: Observer = { diff --git a/public/app/features/variables/state/types.ts b/public/app/features/variables/state/types.ts index c71db7299ca..9ae053a4458 100644 --- a/public/app/features/variables/state/types.ts +++ b/public/app/features/variables/state/types.ts @@ -17,7 +17,7 @@ export interface KeyedVariableIdentifier { rootStateKey: string; } -export interface VariablePayload extends VariableIdentifier { +export interface VariablePayload extends VariableIdentifier { data: T; } diff --git a/public/app/features/variables/utils.ts b/public/app/features/variables/utils.ts index b3bd198f570..4ab42c8ec5c 100644 --- a/public/app/features/variables/utils.ts +++ b/public/app/features/variables/utils.ts @@ -279,12 +279,9 @@ export const toKeyedVariableIdentifier = (variable: VariableModel): KeyedVariabl return { type: variable.type, id: variable.id, rootStateKey: variable.rootStateKey }; }; -export function toVariablePayload( - identifier: VariableIdentifier, - data?: T -): VariablePayload; -export function toVariablePayload(model: VariableModel, data?: T): VariablePayload; -export function toVariablePayload( +export function toVariablePayload(identifier: VariableIdentifier, data?: T): VariablePayload; +export function toVariablePayload(model: VariableModel, data?: T): VariablePayload; +export function toVariablePayload( obj: VariableIdentifier | VariableModel, data?: T ): VariablePayload { diff --git a/public/app/plugins/datasource/alertmanager/DataSource.ts b/public/app/plugins/datasource/alertmanager/DataSource.ts index 315e85864c6..30bf2dd7316 100644 --- a/public/app/plugins/datasource/alertmanager/DataSource.ts +++ b/public/app/plugins/datasource/alertmanager/DataSource.ts @@ -42,7 +42,7 @@ export class AlertManagerDatasource extends DataSourceApi(options)); + return lastValueFrom(getBackendSrv().fetch(options)); } async testDatasource() { diff --git a/public/app/types/jquery/jquery.d.ts b/public/app/types/jquery/jquery.d.ts index 4a6f60b6029..84b7ed5a37d 100644 --- a/public/app/types/jquery/jquery.d.ts +++ b/public/app/types/jquery/jquery.d.ts @@ -12,6 +12,5 @@ interface JQuery { modal: any; tagsinput: any; typeahead: any; - accessKey: any; tooltip: any; }