Chore: Type fixes (#103340)

* tidy tidy

* more fixes

* some TableNG fixes

* another TableNG test fix

* some more fixes

* betterer...
pull/103530/head
Ashley Harrison 1 month ago committed by GitHub
parent 68c6e88b00
commit 641031cfaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 165
      .betterer.results
  2. 11
      packages/grafana-ui/src/components/SingleStatShared/SingleStatBaseOptions.ts
  3. 23
      packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx
  4. 4
      packages/grafana-ui/src/components/Table/TableNG/Cells/HeaderCell.tsx
  5. 14
      packages/grafana-ui/src/components/Table/TableNG/TableNG.test.tsx
  6. 17
      packages/grafana-ui/src/components/Table/TableNG/TableNG.tsx
  7. 10
      packages/grafana-ui/src/components/Table/TableNG/utils.test.ts
  8. 4
      packages/grafana-ui/src/themes/stylesFactory.ts
  9. 9
      packages/grafana-ui/src/types/jquery.d.ts
  10. 4
      packages/grafana-ui/src/types/mdx.d.ts
  11. 10
      packages/grafana-ui/src/utils/dom.ts
  12. 2
      public/app/features/explore/Logs/Logs.tsx
  13. 16
      public/app/features/explore/Logs/LogsContainer.tsx
  14. 2
      public/app/features/manage-dashboards/state/actions.ts
  15. 6
      public/app/features/org/state/actions.ts
  16. 2
      public/app/features/panel/panellinks/link_srv.ts
  17. 15
      public/app/features/plugins/datasource_srv.ts
  18. 2
      public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts
  19. 12
      public/app/features/query/state/updateQueries.test.ts
  20. 6
      public/app/features/search/service/sql.ts
  21. 10
      public/app/features/search/service/types.ts
  22. 8
      public/app/features/teams/TeamGroupSync.tsx
  23. 5
      public/app/features/transformers/FilterByValueTransformer/ValueMatchers/NoopMatcherEditor.tsx
  24. 2
      public/app/features/transformers/FilterByValueTransformer/ValueMatchers/RangeMatcherEditor.tsx
  25. 10
      public/app/features/transformers/extractFields/extractFields.ts
  26. 2
      public/app/features/transformers/lookupGazetteer/fieldLookup.ts
  27. 2
      public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.test.ts
  28. 4
      public/app/features/transformers/prepareTimeSeries/prepareTimeSeries.ts
  29. 1
      public/app/features/variables/adhoc/picker/AdHocFilterRenderer.tsx
  30. 2
      public/app/features/variables/datasource/actions.ts
  31. 2
      public/app/features/variables/editor/VariableEditorEditor.tsx
  32. 2
      public/app/features/variables/editor/reducer.ts
  33. 2
      public/app/features/variables/editor/types.ts
  34. 3
      public/app/features/variables/guard.ts
  35. 4
      public/app/features/variables/inspect/NetworkGraph.tsx
  36. 4
      public/app/features/variables/inspect/utils.ts
  37. 4
      public/app/features/variables/query/actions.ts
  38. 2
      public/app/features/variables/query/operators.ts
  39. 5
      public/app/features/variables/query/queryRunners.test.ts
  40. 4
      public/app/features/variables/query/variableQueryObserver.ts
  41. 2
      public/app/features/variables/state/types.ts
  42. 9
      public/app/features/variables/utils.ts
  43. 2
      public/app/plugins/datasource/alertmanager/DataSource.ts
  44. 1
      public/app/types/jquery/jquery.d.ts

@ -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 <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
],
"public/app/features/explore/Logs/LogsColumnSearch.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> 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 <Trans />", "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 <Trans />", "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 <Trans /> or use t()", "2"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "3"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "4"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "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 <Trans />", "5"]
],
"public/app/features/teams/TeamList.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> 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 <Trans />", "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 <Trans /> or use t()", "1"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> 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 <Trans /> or use t()", "1"],
@ -3328,13 +3248,6 @@ exports[`better eslint`] = {
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "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 <Trans /> 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 <Trans /> 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 <Trans />", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "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 <Trans /> 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 <Trans />", "0"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "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"],

@ -117,12 +117,12 @@ function migrateFromGraphPanel(panel: PanelModel<Partial<SingleStatBaseOptions>>
function migrateFromAngularSinglestat(panel: PanelModel<Partial<SingleStatBaseOptions>> | 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<Partial<SingleStatBaseOp
export function sharedSingleStatMigrationHandler(panel: PanelModel<SingleStatBaseOptions>): 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');

@ -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<any, State> {
constructor(props: any) {
class WrapperWithState extends PureComponent<Props, State> {
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;

@ -62,7 +62,7 @@ const HeaderCell: React.FC<HeaderCellProps> = ({
const handleSort = (event: React.MouseEvent<HTMLButtonElement>) => {
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<HeaderCellProps> = ({
if (lastElement) {
const handleMouseUp = () => {
let newWidth = headerCellParent.clientWidth;
onColumnResize?.(column.key as string, newWidth);
onColumnResize?.(column.key, newWidth);
};
lastElement.addEventListener('click', handleMouseUp);

@ -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,

@ -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<ColumnTypes>((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<HTMLDivElement>) => {
const target = event.target as HTMLDivElement;
const target = event.currentTarget;
scrollPositionRef.current = {
x: target.scrollLeft,
y: target.scrollTop,

@ -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),
}),

@ -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<ResultFn extends (this: any, ...newArgs: any[]) => ReturnType<ResultFn>>(
stylesCreator: ResultFn
) {
export function stylesFactory<ResultFn extends (...newArgs: any[]) => ReturnType<ResultFn>>(stylesCreator: ResultFn) {
return memoize(stylesCreator);
}

@ -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;
}

@ -1,4 +0,0 @@
declare module '*.mdx' {
let MDXComponent: (props: any) => JSX.Element;
export default MDXComponent;
}

@ -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;

@ -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<any>;
getRowContext?: (row: LogRowModel, origRow: LogRowModel, options: LogRowContextOptions) => Promise<DataQueryResponse>;
getRowContextQuery?: (
row: LogRowModel,
options?: LogRowContextOptions,

@ -164,20 +164,28 @@ class LogsContainer extends PureComponent<LogsContainerProps, LogsContainerState
row: LogRowModel,
origRow: LogRowModel,
options: LogRowContextOptions
): Promise<DataQueryResponse | []> => {
): Promise<DataQueryResponse> => {
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 (

@ -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<DashboardSearchHit[]> {

@ -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<any> {
): ThunkResult<Promise<UserOrg[]>> {
return async (dispatch) => {
const result = await dependencies.getBackendSrv().get('/api/user/orgs');
const result = await dependencies.getBackendSrv().get<UserOrg[]>('/api/user/orgs');
dispatch(userOrganizationsLoaded(result));
return result;

@ -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;

@ -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;

@ -43,7 +43,7 @@ class DashboardQueryRunnerImpl implements DashboardQueryRunner {
this.executeRun = this.executeRun.bind(this);
this.results = new ReplaySubject<DashboardQueryRunnerWorkerResult>(1);
this.runs = new Subject<DashboardQueryRunnerOptions>();
this.cancellationStream = new Subject<any>();
this.cancellationStream = new Subject<AnnotationQuery>();
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() });

@ -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);

@ -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<SortOptions>('/api/search/sorting');
return opts.sortOptions.map((v) => ({
value: v.name,
label: v.displayName,
}));

@ -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;

@ -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<Props, State> {
this.setState({ isAdding: !this.state.isAdding });
};
onNewGroupIdChanged = (event: any) => {
this.setState({ newGroupId: event.target.value });
onNewGroupIdChanged: FormEventHandler<HTMLInputElement> = (event) => {
this.setState({ newGroupId: event.currentTarget.value });
};
onAddGroup = (event: any) => {
onAddGroup: FormEventHandler<HTMLFormElement> = (event) => {
event.preventDefault();
this.props.addTeamGroup(this.state.newGroupId);
this.setState({ isAdding: false, newGroupId: '' });

@ -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<ValueMatcherUIRegistryItem<any>> => {
export const getNoopValueMatchersUI = (): Array<ValueMatcherUIRegistryItem<Props>> => {
return [
{
name: 'Is null',

@ -12,7 +12,7 @@ import { ValueMatcherEditorConfig, ValueMatcherUIProps, ValueMatcherUIRegistryIt
type PropNames = 'from' | 'to';
export function rangeMatcherEditor<T = any>(
export function rangeMatcherEditor<T = string | number>(
config: ValueMatcherEditorConfig
): React.FC<ValueMatcherUIProps<RangeValueMatcherOptions<T>>> {
return function RangeMatcherEditor({ options, onChange }) {

@ -53,7 +53,7 @@ export function addExtractedFields(frame: DataFrame, options: ExtractFieldsOptio
const count = frame.length;
const names: string[] = []; // keep order
const values = new Map<string, any[]>();
const values = new Map<string, unknown[]>();
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);
}

@ -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);

@ -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: {},

@ -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<string, any> = {};
const rowValues: Record<string, unknown> = {};
for (const name of uniqueFactorNamesWithWideIndices) {
rowValues[name] = frame.fields[uniqueFactorNamesToWideIndex[name]].values[wideRowIndex];

@ -12,7 +12,6 @@ interface Props {
onOperatorChange: (item: SelectableValue<string>) => void;
onValueChange: (item: SelectableValue<string>) => void;
placeHolder?: string;
getTagKeysOptions?: any;
disabled?: boolean;
}

@ -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();

@ -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,

@ -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;

@ -6,7 +6,7 @@ export enum VariableNameConstraints {
export interface OnPropChangeArguments<Model extends VariableModel = VariableModel> {
propName: keyof Model;
propValue: any;
propValue: unknown;
updateOptions?: boolean;
}

@ -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<TQuery, TOptions> {
metricFindQuery(query: any, options?: any): Promise<MetricFindValue[]>;
metricFindQuery(query: string, options?: LegacyMetricFindQueryOptions): Promise<MetricFindValue[]>;
variables: undefined;
}

@ -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);
}

@ -125,7 +125,7 @@ const validVariableNames: Record<string, RegExp[]> = {
};
export const getPropsWithVariable = (variableId: string, parent: { key: string; value: any }, result: any) => {
const stringValues = Object.keys(parent.value).reduce<Record<string, any>>((all, key) => {
const stringValues = Object.keys(parent.value).reduce<Record<string, string>>((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<Record<string, any>>((all, key) => {
const objectValues = Object.keys(parent.value).reduce<Record<string, object>>((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;

@ -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 };
}

@ -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;
}

@ -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 = {

@ -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<UpdateOptionsResults> {
const observer: Observer<UpdateOptionsResults> = {

@ -17,7 +17,7 @@ export interface KeyedVariableIdentifier {
rootStateKey: string;
}
export interface VariablePayload<T extends any = undefined> extends VariableIdentifier {
export interface VariablePayload<T = undefined> extends VariableIdentifier {
data: T;
}

@ -279,12 +279,9 @@ export const toKeyedVariableIdentifier = (variable: VariableModel): KeyedVariabl
return { type: variable.type, id: variable.id, rootStateKey: variable.rootStateKey };
};
export function toVariablePayload<T extends any = undefined>(
identifier: VariableIdentifier,
data?: T
): VariablePayload<T>;
export function toVariablePayload<T extends any = undefined>(model: VariableModel, data?: T): VariablePayload<T>;
export function toVariablePayload<T extends any = undefined>(
export function toVariablePayload<T = undefined>(identifier: VariableIdentifier, data?: T): VariablePayload<T>;
export function toVariablePayload<T = undefined>(model: VariableModel, data?: T): VariablePayload<T>;
export function toVariablePayload<T = undefined>(
obj: VariableIdentifier | VariableModel,
data?: T
): VariablePayload<T> {

@ -42,7 +42,7 @@ export class AlertManagerDatasource extends DataSourceApi<AlertManagerQuery, Ale
options.headers!.Authorization = this.instanceSettings.basicAuth;
}
return lastValueFrom(getBackendSrv().fetch<any>(options));
return lastValueFrom(getBackendSrv().fetch(options));
}
async testDatasource() {

@ -12,6 +12,5 @@ interface JQuery {
modal: any;
tagsinput: any;
typeahead: any;
accessKey: any;
tooltip: any;
}

Loading…
Cancel
Save