Chore: More typescript improvements 💪 (#68699)

* fix some anys

* some canvas/geomap improvements

* some more panel type fixes

* just omit the type in TagOption
This commit is contained in:
Ashley Harrison
2023-05-22 11:53:58 +01:00
committed by GitHub
parent 623c014cda
commit e8ca3c0409
48 changed files with 187 additions and 298 deletions

View File

@@ -1458,9 +1458,6 @@ exports[`better eslint`] = {
"public/app/core/components/ForgottenPassword/ChangePassword.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
"public/app/core/components/Login/LoginCtrl.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/components/Login/LoginForm.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"]
@@ -1474,89 +1471,82 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Do not use any type assertions.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Do not use any type assertions.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Do not use any type assertions.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Do not use any type assertions.", "25"],
[0, 0, 0, "Unexpected any. Specify a different type.", "26"],
[0, 0, 0, "Do not use any type assertions.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"],
[0, 0, 0, "Do not use any type assertions.", "29"],
[0, 0, 0, "Do not use any type assertions.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Do not use any type assertions.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Do not use any type assertions.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Do not use any type assertions.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Do not use any type assertions.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Do not use any type assertions.", "28"],
[0, 0, 0, "Unexpected any. Specify a different type.", "29"],
[0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Do not use any type assertions.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"],
[0, 0, 0, "Do not use any type assertions.", "34"],
[0, 0, 0, "Do not use any type assertions.", "33"],
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Do not use any type assertions.", "36"],
[0, 0, 0, "Unexpected any. Specify a different type.", "37"],
[0, 0, 0, "Unexpected any. Specify a different type.", "38"],
[0, 0, 0, "Do not use any type assertions.", "39"],
[0, 0, 0, "Do not use any type assertions.", "38"],
[0, 0, 0, "Unexpected any. Specify a different type.", "39"],
[0, 0, 0, "Unexpected any. Specify a different type.", "40"],
[0, 0, 0, "Do not use any type assertions.", "41"],
[0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Unexpected any. Specify a different type.", "43"],
[0, 0, 0, "Do not use any type assertions.", "44"],
[0, 0, 0, "Do not use any type assertions.", "43"],
[0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Unexpected any. Specify a different type.", "45"],
[0, 0, 0, "Do not use any type assertions.", "46"],
[0, 0, 0, "Unexpected any. Specify a different type.", "47"],
[0, 0, 0, "Unexpected any. Specify a different type.", "48"],
[0, 0, 0, "Do not use any type assertions.", "49"],
[0, 0, 0, "Do not use any type assertions.", "48"],
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
[0, 0, 0, "Do not use any type assertions.", "51"],
[0, 0, 0, "Unexpected any. Specify a different type.", "52"],
[0, 0, 0, "Unexpected any. Specify a different type.", "53"],
[0, 0, 0, "Do not use any type assertions.", "54"],
[0, 0, 0, "Do not use any type assertions.", "53"],
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Do not use any type assertions.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Unexpected any. Specify a different type.", "58"],
[0, 0, 0, "Do not use any type assertions.", "59"],
[0, 0, 0, "Do not use any type assertions.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Do not use any type assertions.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"],
[0, 0, 0, "Unexpected any. Specify a different type.", "63"],
[0, 0, 0, "Do not use any type assertions.", "64"],
[0, 0, 0, "Do not use any type assertions.", "63"],
[0, 0, 0, "Unexpected any. Specify a different type.", "64"],
[0, 0, 0, "Unexpected any. Specify a different type.", "65"],
[0, 0, 0, "Do not use any type assertions.", "66"],
[0, 0, 0, "Unexpected any. Specify a different type.", "67"],
[0, 0, 0, "Unexpected any. Specify a different type.", "68"],
[0, 0, 0, "Do not use any type assertions.", "69"],
[0, 0, 0, "Do not use any type assertions.", "68"],
[0, 0, 0, "Unexpected any. Specify a different type.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Unexpected any. Specify a different type.", "73"],
[0, 0, 0, "Do not use any type assertions.", "74"],
[0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"],
[0, 0, 0, "Do not use any type assertions.", "76"],
[0, 0, 0, "Unexpected any. Specify a different type.", "77"],
[0, 0, 0, "Unexpected any. Specify a different type.", "78"],
[0, 0, 0, "Do not use any type assertions.", "79"],
[0, 0, 0, "Unexpected any. Specify a different type.", "80"],
[0, 0, 0, "Do not use any type assertions.", "81"],
[0, 0, 0, "Unexpected any. Specify a different type.", "82"],
[0, 0, 0, "Do not use any type assertions.", "83"],
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Do not use any type assertions.", "85"],
[0, 0, 0, "Unexpected any. Specify a different type.", "86"]
],
"public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "78"],
[0, 0, 0, "Unexpected any. Specify a different type.", "79"],
[0, 0, 0, "Do not use any type assertions.", "80"],
[0, 0, 0, "Unexpected any. Specify a different type.", "81"],
[0, 0, 0, "Do not use any type assertions.", "82"],
[0, 0, 0, "Unexpected any. Specify a different type.", "83"]
],
"public/app/core/components/PasswordField/PasswordField.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
@@ -1577,40 +1567,25 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
],
"public/app/core/components/TagFilter/TagOption.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/components/TimelineChart/TimelineChart.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/components/connectWithCleanUp.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/core/components/modals/AngularModalProxy.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/navigation/GrafanaRoute.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/navigation/__mocks__/routeProps.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/navigation/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/reducers/root.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/services/ResponseQueue.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/services/backend_srv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -1633,10 +1608,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "17"]
],
"public/app/core/services/context_srv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/core/services/echo/backends/analytics/ApplicationInsightsBackend.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -1681,9 +1654,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/core/utils/acl.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/core/utils/connectWithReduxStore.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -1706,13 +1676,8 @@ exports[`better eslint`] = {
[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, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
],
"public/app/core/utils/fetch.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -1728,16 +1693,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "10"]
],
"public/app/core/utils/flatten.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"]
],
"public/app/core/utils/kbn.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/utils/object.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -2078,25 +2034,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/features/canvas/elements/droneFront.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/droneSide.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/droneTop.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/elements/notFound.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/canvas/elements/windTurbine.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/canvas/runtime/element.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -2192,9 +2132,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/HelpWizard/randomizer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/components/Inspector/PanelInspector.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@@ -2246,9 +2183,6 @@ exports[`better eslint`] = {
[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"]
],
"public/app/features/dashboard/components/SaveDashboard/SaveDashboardErrorProxy.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@@ -2259,12 +2193,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "3"]
],
"public/app/features/dashboard/components/SaveDashboard/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/SaveDashboard/useDashboardSave.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/components/ShareModal/ShareExport.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -2284,12 +2216,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"]
],
"public/app/features/dashboard/components/VersionHistory/__mocks__/dashboardHistoryMocks.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"]
],
"public/app/features/dashboard/components/VersionHistory/useDashboardRestore.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -2314,9 +2240,6 @@ exports[`better eslint`] = {
"public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/dashboard/dashgrid/LazyLoader.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/dashgrid/PanelChromeAngular.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
@@ -2337,24 +2260,14 @@ exports[`better eslint`] = {
[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"]
],
"public/app/features/dashboard/services/DashboardSrv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/services/TimeSrv.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.", "1"]
],
"public/app/features/dashboard/state/DashboardMigrator.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5072,28 +4985,15 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"]
],
"public/app/plugins/panel/canvas/CanvasPanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/panel/canvas/InlineEdit.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/canvas/InlineEditBody.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, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/panel/canvas/editor/APIEditor.tsx:5381": [
[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, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/canvas/editor/PlacementEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -5117,9 +5017,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/panel/canvas/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/dashlist/module.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@@ -5141,9 +5038,7 @@ exports[`better eslint`] = {
"public/app/plugins/panel/geomap/components/MarkersLegend.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, "Unexpected any. Specify a different type.", "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.", "2"]
],
"public/app/plugins/panel/geomap/components/MeasureVectorLayer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -5172,9 +5067,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/panel/geomap/layers/basemaps/carto.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/geomap/layers/basemaps/esri.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@@ -5187,10 +5079,7 @@ exports[`better eslint`] = {
],
"public/app/plugins/panel/geomap/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/geomap/utils/layers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5200,8 +5089,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/geomap/utils/tootltip.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/graph/GraphContextMenuCtrl.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5546,11 +5434,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/panel/heatmap/HeatmapHoverView.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"]
],
"public/app/plugins/panel/heatmap/HeatmapPanel.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5595,8 +5478,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Do not use any type assertions.", "17"],
[0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"]
[0, 0, 0, "Do not use any type assertions.", "18"]
],
"public/app/plugins/panel/histogram/Histogram.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -5621,9 +5503,7 @@ exports[`better eslint`] = {
"public/app/plugins/panel/live/LivePanel.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/panel/live/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -5653,12 +5533,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/plugins/panel/nodeGraph/usePanning.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -5839,12 +5713,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/panel/timeseries/SpanNullsEditor.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.", "3"]
],
"public/app/plugins/panel/timeseries/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@@ -5874,12 +5742,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/timeseries/suggestions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/trend/suggestions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/xychart/AutoEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]

View File

@@ -240,6 +240,7 @@ export class AsyncSelect<T> extends PureComponent<AsyncProps<T>> {
value={value}
//@ts-expect-error
getOptionLabel={getOptionLabel}
//@ts-expect-error
getOptionValue={getOptionValue}
menuShouldScrollIntoView={false}
onChange={onChange}

View File

@@ -37,7 +37,7 @@ export interface SelectCommonProps<T> {
/** Function for formatting the text that is displayed when creating a new value*/
formatCreateLabel?: (input: string) => string;
getOptionLabel?: (item: SelectableValue<T>) => React.ReactNode;
getOptionValue?: (item: SelectableValue<T>) => string;
getOptionValue?: (item: SelectableValue<T>) => T | undefined;
hideSelectedOptions?: boolean;
inputValue?: string;
invalid?: boolean;

View File

@@ -5,6 +5,8 @@ import { getBackendSrv } from '@grafana/runtime';
import appEvents from 'app/core/app_events';
import config from 'app/core/config';
import { LoginDTO } from './types';
const isOauthEnabled = () => {
return !!config.oauth && Object.keys(config.oauth).length > 0;
};
@@ -38,7 +40,7 @@ interface State {
}
export class LoginCtrl extends PureComponent<Props, State> {
result: any = {};
result: LoginDTO | undefined;
constructor(props: Props) {
super(props);
@@ -87,7 +89,7 @@ export class LoginCtrl extends PureComponent<Props, State> {
});
getBackendSrv()
.post('/login', formModel)
.post<LoginDTO>('/login', formModel)
.then((result) => {
this.result = result;
if (formModel.password !== 'admin' || config.ldapEnabled || config.authProxyEnabled) {
@@ -112,7 +114,7 @@ export class LoginCtrl extends PureComponent<Props, State> {
toGrafana = () => {
// Use window.location.href to force page reload
if (this.result.redirectUrl) {
if (this.result?.redirectUrl) {
if (config.appSubUrl !== '' && !this.result.redirectUrl.startsWith(config.appSubUrl)) {
window.location.assign(config.appSubUrl + this.result.redirectUrl);
} else {

View File

@@ -0,0 +1,4 @@
export interface LoginDTO {
message: string;
redirectUrl: string;
}

View File

@@ -87,21 +87,21 @@ export const getAllOptionEditors = () => {
},
};
const select: StandardEditorsRegistryItem<any> = {
const select: StandardEditorsRegistryItem = {
id: 'select',
name: 'Select',
description: 'Allows option selection',
editor: SelectValueEditor as any,
};
const multiSelect: StandardEditorsRegistryItem<any> = {
const multiSelect: StandardEditorsRegistryItem = {
id: 'multi-select',
name: 'Multi select',
description: 'Allows for multiple option selection',
editor: MultiSelectValueEditor as any,
};
const radio: StandardEditorsRegistryItem<any> = {
const radio: StandardEditorsRegistryItem = {
id: 'radio',
name: 'Radio',
description: 'Allows option selection',

View File

@@ -32,8 +32,8 @@ export const PanelTypeFilter = ({ onChange: propsOnChange, maxMenuHeight }: Prop
const selectOptions = {
defaultOptions: true,
getOptionLabel: (i: any) => i.label,
getOptionValue: (i: any) => i.value,
getOptionLabel: (i: SelectableValue<PanelPluginMeta>) => i.label,
getOptionValue: (i: SelectableValue<PanelPluginMeta>) => i.value,
noOptionsMessage: 'No Panel types found',
placeholder: 'Filter by type',
maxMenuHeight,
@@ -56,7 +56,7 @@ export const PanelTypeFilter = ({ onChange: propsOnChange, maxMenuHeight }: Prop
Clear types
</Button>
)}
<MultiSelect {...selectOptions} prefix={<Icon name="filter" />} aria-label="Panel Type filter" />
<MultiSelect<PanelPluginMeta> {...selectOptions} prefix={<Icon name="filter" />} aria-label="Panel Type filter" />
</div>
);
};

View File

@@ -7,7 +7,7 @@ import { useStyles2 } from '@grafana/ui';
import { TagBadge } from './TagBadge';
export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps<any, any>) => {
export const TagOption = ({ data, className, label, isFocused, innerProps }: OptionProps<any>) => {
const styles = useStyles2(getStyles);
return (

View File

@@ -32,7 +32,7 @@ const propsToDiff = ['rowHeight', 'colWidth', 'showValue', 'mergeValues', 'align
export class TimelineChart extends React.Component<TimelineProps> {
declare context: React.ContextType<typeof PanelContextRoot>;
static contextType = PanelContextRoot;
panelContext: PanelContext = {} as PanelContext;
panelContext: PanelContext | undefined;
getValueColor = (frameIdx: number, fieldIdx: number, value: unknown) => {
const field = this.props.frames[frameIdx].fields[fieldIdx];

View File

@@ -7,7 +7,7 @@ import { connectWithProvider } from '../../utils/connectWithReduxStore';
/**
* Component that enables rendering React modals from Angular
*/
export const AngularModalProxy = connectWithProvider((props: any) => {
export const AngularModalProxy = connectWithProvider((props: Record<string, unknown>) => {
return (
<>
<ModalsProvider {...props}>

View File

@@ -9,6 +9,7 @@ import { setEchoSrv } from '@grafana/runtime';
import { Echo } from '../services/echo/Echo';
import { GrafanaRoute, Props } from './GrafanaRoute';
import { GrafanaRouteComponentProps } from './types';
function setup(overrides: Partial<Props>) {
const props: Props = {
@@ -35,14 +36,14 @@ describe('GrafanaRoute', () => {
});
it('Parses search', () => {
let capturedProps: any;
const PageComponent = (props: any) => {
let capturedProps: GrafanaRouteComponentProps;
const PageComponent = (props: GrafanaRouteComponentProps) => {
capturedProps = props;
return <div />;
};
setup({ route: { component: PageComponent, path: '' } });
expect(capturedProps.queryParams.query).toBe('hello');
expect(capturedProps!.queryParams.query).toBe('hello');
});
it('Shows loading on lazy load', async () => {

View File

@@ -9,10 +9,16 @@ export function getRouteComponentProps<T extends {} = {}, Q extends Record<strin
const defaults: GrafanaRouteComponentProps<T, Q> = {
history: createMemoryHistory(),
location: {
hash: '',
pathname: '',
state: {},
search: '',
} as any,
},
match: { params: {} } as any,
route: {} as any,
route: {
path: '',
component: () => null,
},
queryParams: {} as any,
};

View File

@@ -12,7 +12,7 @@ export type GrafanaRouteComponent<T extends {} = any> = React.ComponentType<Graf
export interface RouteDescriptor {
path: string;
component: GrafanaRouteComponent<any>;
component: GrafanaRouteComponent;
roles?: () => string[];
pageClass?: string;
/** Can be used like an id for the route if the same component is used by many routes */

View File

@@ -16,8 +16,8 @@ interface FetchResponsesEntry<T> {
}
export class ResponseQueue {
private queue: Subject<FetchWorkEntry> = new Subject<FetchWorkEntry>(); // internal stream for requests that are to be executed
private responses: Subject<FetchResponsesEntry<any>> = new Subject<FetchResponsesEntry<any>>(); // external stream with responses from fetch
private queue = new Subject<FetchWorkEntry>(); // internal stream for requests that are to be executed
private responses = new Subject<FetchResponsesEntry<any>>(); // external stream with responses from fetch
constructor(fetchQueue: FetchQueue, fetch: <T>(options: BackendSrvRequest) => Observable<FetchResponse<T>>) {
// This will create an implicit live subscription for as long as this class lives.

View File

@@ -63,8 +63,6 @@ export class User implements Omit<CurrentUserInternal, 'lightTheme'> {
}
export class ContextSrv {
pinned: any;
version: any;
user: User;
isSignedIn: boolean;
isGrafanaAdmin: boolean;

View File

@@ -5,7 +5,7 @@ export function processAclItems(items: DashboardAclDTO[]): DashboardAcl[] {
}
function processAclItem(dto: DashboardAclDTO): DashboardAcl {
const item = dto as DashboardAcl;
const item: DashboardAcl = dto;
item.sortRank = 0;

View File

@@ -195,7 +195,7 @@ export const safeParseJson = (text?: string): any | undefined => {
}
};
export const safeStringifyValue = (value: any, space?: number) => {
export const safeStringifyValue = (value: unknown, space?: number) => {
if (value === undefined || value === null) {
return '';
}
@@ -469,8 +469,8 @@ export const getTimeRangeFromUrl = (
};
return {
from: dateMath.parse(raw.from, false, timeZone as any)!,
to: dateMath.parse(raw.to, true, timeZone as any)!,
from: dateMath.parse(raw.from, false, timeZone)!,
to: dateMath.parse(raw.to, true, timeZone)!,
raw,
};
};

View File

@@ -1,13 +1,16 @@
// Copyright (c) 2014, Hugh Kennedy
// Based on code from https://github.com/hughsk/flat/blob/master/index.js
//
export default function flatten(target: object, opts?: { delimiter?: any; maxDepth?: any; safe?: any }): any {
export default function flatten(
target: object,
opts?: { delimiter?: string; maxDepth?: number; safe?: boolean }
): Record<string, unknown> {
opts = opts || {};
const delimiter = opts.delimiter || '.';
let maxDepth = opts.maxDepth || 3;
let currentDepth = 1;
const output: any = {};
const output: Record<string, unknown> = {};
function step(object: any, prev: string | null) {
Object.keys(object).forEach((key) => {

View File

@@ -12,8 +12,9 @@ import {
escapeRegex,
} from '@grafana/data';
const valueFormats: ValueFormatterIndex = {};
const kbn = {
valueFormats: {} as ValueFormatterIndex,
valueFormats,
intervalRegex: /(\d+(?:\.\d+)?)(ms|[Mwdhmsy])/,
intervalsInSeconds: {
y: 31536000,
@@ -24,7 +25,7 @@ const kbn = {
m: 60,
s: 1,
ms: 0.001,
} as { [index: string]: number },
} as const,
/** @deprecated since 9.4, use grafana/data */
regexEscape: (value: string): string => {
deprecationWarning('kbn.ts', 'kbn.regexEscape()', 'escapeRegex from @grafana/data');

View File

@@ -69,7 +69,7 @@ const DroneFrontDisplay = ({ data }: CanvasElementProps<DroneFrontConfig, DroneF
);
};
export const droneFrontItem: CanvasElementItem<any, any> = {
export const droneFrontItem: CanvasElementItem = {
id: 'droneFront',
name: 'Drone Front',
description: 'Drone front',

View File

@@ -68,7 +68,7 @@ const DroneSideDisplay = ({ data }: CanvasElementProps<DroneSideConfig, DroneSid
);
};
export const droneSideItem: CanvasElementItem<any, any> = {
export const droneSideItem: CanvasElementItem = {
id: 'droneSide',
name: 'Drone Side',
description: 'Drone Side',

View File

@@ -80,7 +80,7 @@ const DroneTopDisplay = ({ data }: CanvasElementProps<DroneTopConfig, DroneTopDa
);
};
export const droneTopItem: CanvasElementItem<any, any> = {
export const droneTopItem: CanvasElementItem = {
id: 'droneTop',
name: 'Drone Top',
description: 'Drone top',

View File

@@ -64,7 +64,7 @@ const WindTurbineDisplay = ({ data }: CanvasElementProps<WindTurbineConfig, Wind
);
};
export const windTurbineItem: CanvasElementItem<any, any> = {
export const windTurbineItem: CanvasElementItem = {
id: 'windTurbine',
name: 'Wind Turbine',
description: 'Spinny spinny',

View File

@@ -66,8 +66,7 @@ export function randomizeData(data: DataFrameJSON[], opts: Randomize): DataFrame
if (opts.values) {
schema.fields.forEach((f, idx) => {
if (f.type === FieldType.string && data) {
// eslint-ignore-next-line
const v = data.values[idx].map((v) => rand(v as string));
const v = data.values[idx].map((v) => rand(String(v)));
data.values[idx] = v;
}
});

View File

@@ -14,7 +14,7 @@ interface SaveDashboardErrorProxyProps {
/** original dashboard */
dashboard: DashboardModel;
/** dashboard save model with applied modifications, i.e. title */
dashboardSaveModel: any;
dashboardSaveModel: DashboardModel;
error: FetchError;
onDismiss: () => void;
}

View File

@@ -28,7 +28,7 @@ export interface SaveDashboardFormProps {
dashboard: DashboardModel;
onCancel: () => void;
onSuccess: () => void;
onSubmit?: (clone: any, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>;
onSubmit?: (clone: DashboardModel, options: SaveDashboardOptions, dashboard: DashboardModel) => Promise<any>;
}
export interface SaveDashboardModalProps {

View File

@@ -29,7 +29,7 @@ export const useDashboardSave = (dashboard: DashboardModel, isCopy = false) => {
const dispatch = useDispatch();
const notifyApp = useAppNotification();
const [state, onDashboardSave] = useAsyncFn(
async (clone: any, options: SaveDashboardOptions, dashboard: DashboardModel) => {
async (clone: DashboardModel, options: SaveDashboardOptions, dashboard: DashboardModel) => {
try {
const result = await saveDashboard(clone, options, dashboard);
dashboard.version = result.version;

View File

@@ -48,11 +48,7 @@ export function versions() {
];
}
export function compare(type: any) {
return type === 'basic' ? '<div></div>' : '<pre><code></code></pre>';
}
export function restore(version: any, restoredFrom?: any): any {
export function restore(version: number, restoredFrom?: number) {
return {
dashboard: {
meta: {

View File

@@ -50,7 +50,8 @@ export function LazyLoader({ children, width, height, onLoad, onChange }: Props)
);
}
LazyLoader.callbacks = {} as Record<string, (e: IntersectionObserverEntry) => void>;
const callbacks: Record<string, (e: IntersectionObserverEntry) => void> = {};
LazyLoader.callbacks = callbacks;
LazyLoader.addCallback = (id: string, c: (e: IntersectionObserverEntry) => void) => (LazyLoader.callbacks[id] = c);
LazyLoader.observer = new IntersectionObserver(
(entries) => {

View File

@@ -48,7 +48,7 @@ export class DashboardLoaderSrv {
} else if (type === 'public') {
promise = backendSrv
.getPublicDashboardByUid(uid)
.then((result: any) => {
.then((result) => {
return result;
})
.catch((e) => {
@@ -73,7 +73,7 @@ export class DashboardLoaderSrv {
} else {
promise = backendSrv
.getDashboardByUid(uid)
.then((result: any) => {
.then((result) => {
if (result.meta.isFolder) {
appEvents.emit(AppEvents.alertError, ['Dashboard not found']);
throw new Error('Dashboard not found');
@@ -114,7 +114,7 @@ export class DashboardLoaderSrv {
dashboard: result.data,
};
},
(err: any) => {
(err) => {
console.error('Script dashboard error ' + err);
appEvents.emit(AppEvents.alertError, [
'Script Error',
@@ -142,7 +142,7 @@ export class DashboardLoaderSrv {
return Promise.reject('expecting path parameter');
}
const queryParams: { [key: string]: any } = {};
const queryParams: { [key: string]: string } = {};
params.forEach((value, key) => {
queryParams[key] = value;

View File

@@ -2,6 +2,7 @@ import { lastValueFrom } from 'rxjs';
import { AppEvents } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime';
import { Dashboard } from '@grafana/schema';
import { appEvents } from 'app/core/app_events';
import { t } from 'app/core/internationalization';
import { getBackendSrv } from 'app/core/services/backend_srv';
@@ -45,7 +46,7 @@ export class DashboardSrv {
appEvents.subscribe(RemovePanelEvent, (e) => this.onRemovePanel(e.payload));
}
create(dashboard: any, meta: DashboardMeta) {
create(dashboard: Dashboard, meta: DashboardMeta) {
return new DashboardModel(dashboard, meta);
}

View File

@@ -22,17 +22,18 @@ import { TimeModel } from '../state/TimeModel';
import { getRefreshFromUrl } from '../utils/getRefreshFromUrl';
export class TimeSrv {
time: any;
time: RawTimeRange;
refreshTimer: number | undefined;
refresh: any;
oldRefresh: string | null | undefined;
timeModel?: TimeModel;
timeAtLoad: any;
timeAtLoad: RawTimeRange;
private autoRefreshBlocked?: boolean;
constructor(private contextSrv: ContextSrv) {
// default time
this.time = getDefaultTimeRange().raw;
this.timeAtLoad = getDefaultTimeRange().raw;
this.refreshTimeModel = this.refreshTimeModel.bind(this);
appEvents.subscribe(ZoomOutEvent, (e) => {
@@ -105,7 +106,7 @@ export class TimeSrv {
}
}
private parseUrlParam(value: any) {
private parseUrlParam(value: string) {
if (value.indexOf('now') !== -1) {
return value;
}
@@ -121,7 +122,7 @@ export class TimeSrv {
}
}
if (!isNaN(value)) {
if (!isNaN(Number(value))) {
const epoch = parseInt(value, 10);
return toUtc(epoch);
}

View File

@@ -44,7 +44,7 @@ export const activePanelSubject = new ReplaySubject<SelectionAction>(1);
export class CanvasPanel extends Component<Props, State> {
declare context: React.ContextType<typeof PanelContextRoot>;
static contextType = PanelContextRoot;
panelContext: PanelContext = {} as PanelContext;
panelContext: PanelContext | undefined;
readonly scene: Scene;
private subs = new Subscription();
@@ -104,7 +104,7 @@ export class CanvasPanel extends Component<Props, State> {
activeCanvasPanel = this;
activePanelSubject.next({ panel: this });
this.panelContext = this.context as PanelContext;
this.panelContext = this.context;
if (this.panelContext.onInstanceStateChange) {
this.panelContext.onInstanceStateChange({
scene: this.scene,
@@ -126,7 +126,7 @@ export class CanvasPanel extends Component<Props, State> {
}
});
this.panelContext.onInstanceStateChange!({
this.panelContext?.onInstanceStateChange!({
scene: this.scene,
selected: v,
layer: this.scene.root,
@@ -142,7 +142,7 @@ export class CanvasPanel extends Component<Props, State> {
return;
}
this.panelContext.onInstanceStateChange!({
this.panelContext?.onInstanceStateChange!({
scene: this.scene,
selected: this.context.instanceState.selected,
selectedConnection: v,

View File

@@ -1,6 +1,6 @@
import { css } from '@emotion/css';
import React, { SyntheticEvent, useEffect, useRef, useState } from 'react';
import Draggable from 'react-draggable';
import Draggable, { DraggableEventHandler } from 'react-draggable';
import { Resizable, ResizeCallbackData } from 'react-resizable';
import { Dimensions2D, GrafanaTheme2 } from '@grafana/data';
@@ -53,7 +53,7 @@ export function InlineEdit({ onClose, id, scene }: Props) {
}
}, [windowHeight, windowWidth, placement, measurements]);
const onDragStop = (event: any, dragElement: any) => {
const onDragStop: DraggableEventHandler = (event, dragElement) => {
let x = dragElement.x < 0 ? 0 : dragElement.x;
let y = dragElement.y < 0 ? 0 : dragElement.y;

View File

@@ -138,8 +138,8 @@ function getOptionsPaneCategoryDescriptor<T = any>(
};
const access: NestedValueAccess = {
getValue: (path: string) => lodashGet(props.options, path),
onChange: (path: string, value: any) => {
getValue: (path) => lodashGet(props.options, path),
onChange: (path, value) => {
props.onChange(setOptionImmutably(props.options as any, path, value));
},
};

View File

@@ -11,9 +11,9 @@ export interface APIEditorConfig {
data?: string;
}
const dummyStringSettings: StandardEditorsRegistryItem<string, StringFieldConfigSettings> = {
const dummyStringSettings = {
settings: {},
} as any;
} as StandardEditorsRegistryItem<string, StringFieldConfigSettings>;
export const callApi = (api: APIEditorConfig, isTest = false) => {
if (api) {
@@ -24,7 +24,7 @@ export const callApi = (api: APIEditorConfig, isTest = false) => {
data: api.data ?? {},
})
.subscribe({
error: (error: any) => {
error: (error) => {
if (isTest) {
appEvents.emit(AppEvents.alertError, ['Error has occurred: ', JSON.stringify(error)]);
console.error(error);
@@ -39,7 +39,7 @@ export const callApi = (api: APIEditorConfig, isTest = false) => {
}
};
type Props = StandardEditorProps<APIEditorConfig, any, any>;
type Props = StandardEditorProps<APIEditorConfig>;
export function APIEditor({ value, context, onChange }: Props) {
const labelWidth = 9;

View File

@@ -82,8 +82,11 @@ export function getElementTypesOptions(items: CanvasElementItem[], current: stri
export function onAddItem(sel: SelectableValue<string>, rootLayer: FrameState | undefined, anchorPoint?: AnchorPoint) {
const newItem = canvasElementRegistry.getIfExists(sel.value) ?? notFoundItem;
const newElementOptions = newItem.getNewOptions() as CanvasElementOptions;
newElementOptions.type = newItem.id;
const newElementOptions: CanvasElementOptions = {
...newItem.getNewOptions(),
type: newItem.id,
name: '',
};
if (anchorPoint) {
newElementOptions.placement = { ...newElementOptions.placement, top: anchorPoint.y, left: anchorPoint.x };

View File

@@ -36,13 +36,13 @@ export function MarkersLegend(props: MarkersLegendProps) {
}
const props = hoverEvent.getProperties();
const frame = props.frame as DataFrame; // eslint-disable-line
const frame: DataFrame = props.frame;
if (!frame) {
return undefined;
}
const rowIndex = props.rowIndex as number; // eslint-disable-line
const rowIndex: number = props.rowIndex;
return colorField.values[rowIndex];
}, [hoverEvent, colorField]);
@@ -99,8 +99,8 @@ export function MarkersLegend(props: MarkersLegendProps) {
<ColorScale
hoverValue={hoverValue}
colorPalette={colors}
min={colorRange.min as number}
max={colorRange.max as number}
min={colorRange.min ?? 0}
max={colorRange.max ?? 100}
display={display}
useStopsPercentage={false}
/>

View File

@@ -36,7 +36,7 @@ export const carto: MapLayerRegistryItem<CartoConfig> = {
create: async (map: Map, options: MapLayerOptions<CartoConfig>, eventBus: EventBus, theme: GrafanaTheme2) => ({
init: () => {
const cfg = { ...defaultCartoConfig, ...options.config };
let style = cfg.theme as string;
let style: string | undefined = cfg.theme;
if (!style || style === LayerTheme.Auto) {
style = theme.isDark ? 'dark' : 'light';
}

View File

@@ -153,14 +153,14 @@ export function worldmapToGeomapOptions(angular: any): {
'SE Asia': 'se-asia',
'Last GeoHash': MapCenterID.Coordinates, // MapCenterID.LastPoint,
};
options.view.id = mapCenters[angular.mapCenter as any];
options.view.id = mapCenters[angular.mapCenter];
options.view.lat = asNumber(angular.mapCenterLatitude);
options.view.lon = asNumber(angular.mapCenterLongitude);
return { fieldConfig, options, xform };
}
function asNumber(v: any): number | undefined {
const num = +v;
function asNumber(v: unknown): number | undefined {
const num = Number(v);
return isNaN(num) ? undefined : num;
}

View File

@@ -65,9 +65,9 @@ export const pointerMoveListener = (evt: MapBrowserEvent<MouseEvent>, panel: Geo
//this is used as the generic hover event
if (!hoverPayload.data) {
const props = feature.getProperties();
const frame = props['frame'];
const frame: DataFrame = props['frame'];
if (frame) {
hoverPayload.data = ttip.data = frame as DataFrame;
hoverPayload.data = ttip.data = frame;
hoverPayload.rowIndex = ttip.rowIndex = props['rowIndex'];
}

View File

@@ -39,7 +39,7 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
const yField = data.heatmap?.fields[1];
const countField = data.heatmap?.fields[2];
const xDisp = (v: any) => {
const xDisp = (v: number) => {
if (xField?.display) {
return formattedValueToString(xField.display(v));
}
@@ -57,7 +57,7 @@ const HeatmapHoverCell = ({ data, hover, showHistogram }: Props) => {
// labeled buckets
const meta = readHeatmapRowsCustomMeta(data.heatmap);
const yDisp = yField?.display ? (v: any) => formattedValueToString(yField.display!(v)) : (v: any) => `${v}`;
const yDisp = yField?.display ? (v: string) => formattedValueToString(yField.display!(v)) : (v: string) => `${v}`;
const yValueIdx = index % data.yBucketCount! ?? 0;

View File

@@ -289,8 +289,7 @@ export function prepConfig(opts: PrepConfigOpts) {
return builder; // early abort (avoids error)
}
// eslint-ignore @typescript-eslint/no-explicit-any
const yFieldConfig = yField.config?.custom as FieldConfig | undefined;
const yFieldConfig: FieldConfig | undefined = yField.config?.custom;
const yScale = yFieldConfig?.scaleDistribution ?? { type: ScaleDistribution.Linear };
const yAxisReverse = Boolean(yAxisConfig.reverse);
const isSparseHeatmap = heatmapType === DataFrameType.HeatmapCells && !isHeatmapCellsDense(dataRef.current?.heatmap!);

View File

@@ -192,10 +192,10 @@ export class LivePanel extends PureComponent<Props, State> {
}),
state: LoadingState.Streaming,
} as PanelData;
const props = {
const props: PanelProps = {
...this.props,
options: { frameIndex: 0, showHeader: true },
} as PanelProps<any>;
};
return <TablePanel {...props} data={data} height={height} />;
}
}

View File

@@ -184,11 +184,11 @@ function inBounds(value: number, min: number | undefined, max: number | undefine
}
function getEventXY(event: Event): { x: number; y: number } {
if ((event as any).changedTouches) {
const e = event as TouchEvent;
return { x: e.changedTouches[0].clientX, y: e.changedTouches[0].clientY };
if (event instanceof TouchEvent) {
return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY };
} else if (event instanceof MouseEvent) {
return { x: event.clientX, y: event.clientY };
} else {
const e = event as MouseEvent;
return { x: e.clientX, y: e.clientY };
return { x: 0, y: 0 };
}
}

View File

@@ -22,8 +22,8 @@ type Props = FieldOverrideEditorProps<boolean | number, unknown>;
export const SpanNullsEditor = ({ value, onChange }: Props) => {
const isThreshold = typeof value === 'number';
const formattedTime = isThreshold ? rangeUtil.secondsToHms((value as number) / 1000) : undefined;
GAPS_OPTIONS[2].value = isThreshold ? (value as number) : 3600000; // 1h
const formattedTime = isThreshold ? rangeUtil.secondsToHms(value / 1000) : undefined;
GAPS_OPTIONS[2].value = isThreshold ? value : 3600000; // 1h
const checkAndUpdate = (txt: string) => {
let val: boolean | number = false;
@@ -41,11 +41,11 @@ export const SpanNullsEditor = ({ value, onChange }: Props) => {
if (e.key !== 'Enter') {
return;
}
checkAndUpdate((e.target as any).value);
checkAndUpdate(e.currentTarget.value);
};
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
checkAndUpdate(e.target.value);
checkAndUpdate(e.currentTarget.value);
};
return (

View File

@@ -4,7 +4,14 @@ import {
VisualizationSuggestion,
DataTransformerID,
} from '@grafana/data';
import { GraphDrawStyle, GraphFieldConfig, GraphGradientMode, LineInterpolation, StackingMode } from '@grafana/schema';
import {
GraphDrawStyle,
GraphFieldConfig,
GraphGradientMode,
LineInterpolation,
StackingMode,
VizLegendOptions,
} from '@grafana/schema';
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { SuggestionName } from 'app/types/suggestions';
@@ -22,7 +29,7 @@ export class TimeSeriesSuggestionsSupplier {
name: SuggestionName.LineChart,
pluginId: 'timeseries',
options: {
legend: {} as any,
legend: {} as VizLegendOptions,
},
fieldConfig: {
defaults: {

View File

@@ -1,5 +1,5 @@
import { VisualizationSuggestionsBuilder } from '@grafana/data';
import { GraphDrawStyle, GraphFieldConfig } from '@grafana/schema';
import { GraphDrawStyle, GraphFieldConfig, VizLegendOptions } from '@grafana/schema';
import { SuggestionName } from 'app/types/suggestions';
import { Options } from './panelcfg.gen';
@@ -17,7 +17,7 @@ export class TrendSuggestionsSupplier {
name: SuggestionName.LineChart,
pluginId: 'trend',
options: {
legend: {} as any,
legend: {} as VizLegendOptions,
},
fieldConfig: {
defaults: {