Chore: Remove unnecessary type assertions (#78009)

* Chore: Remove unnecessary type assertions

* betterer
This commit is contained in:
Josh Hunt
2023-11-14 09:17:29 +00:00
committed by GitHub
parent a3ae9d418d
commit 2f2be24e01
21 changed files with 99 additions and 137 deletions

View File

@ -1748,12 +1748,6 @@ exports[`better eslint`] = {
"public/app/features/alerting/components/OptionElement.tsx:5381": [ "public/app/features/alerting/components/OptionElement.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/alerting/getAlertingValidationMessage.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, "Unexpected any. Specify a different type.", "3"]
],
"public/app/features/alerting/state/ThresholdMapper.ts:5381": [ "public/app/features/alerting/state/ThresholdMapper.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@ -2182,9 +2176,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Styles should be written using objects.", "3"],
[0, 0, 0, "Styles should be written using objects.", "4"], [0, 0, 0, "Styles should be written using objects.", "4"]
[0, 0, 0, "Styles should be written using objects.", "5"]
], ],
"public/app/features/alerting/unified/components/receivers/form/TestContactPointModal.tsx:5381": [ "public/app/features/alerting/unified/components/receivers/form/TestContactPointModal.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
@ -2199,12 +2192,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Styles should be written using objects.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "Styles should be written using objects.", "5"],
[0, 0, 0, "Styles should be written using objects.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Styles should be written using objects.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"]
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
], ],
"public/app/features/alerting/unified/components/receivers/form/fields/StringArrayInput.tsx:5381": [ "public/app/features/alerting/unified/components/receivers/form/fields/StringArrayInput.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
@ -2732,8 +2723,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"]
[0, 0, 0, "Do not use any type assertions.", "4"]
], ],
"public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx:5381": [ "public/app/features/annotations/components/StandardAnnotationQueryEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
@ -3280,9 +3270,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"]
], ],
"public/app/features/dashboard/dashgrid/DashboardGrid.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [ "public/app/features/dashboard/dashgrid/DashboardPanel.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
@ -4327,9 +4314,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"] [0, 0, 0, "Do not use any type assertions.", "4"]
], ],
"public/app/features/live/index.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/logs/components/LogDetailsRow.tsx:5381": [ "public/app/features/logs/components/LogDetailsRow.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
@ -4683,9 +4667,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "1"] [0, 0, 0, "Styles should be written using objects.", "1"]
], ],
"public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx:5381": [ "public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
], ],
"public/app/features/plugins/sql/components/visual-query-builder/SQLWhereRow.tsx:5381": [ "public/app/features/plugins/sql/components/visual-query-builder/SQLWhereRow.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
@ -4835,9 +4817,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "2"], [0, 0, 0, "Styles should be written using objects.", "2"],
[0, 0, 0, "Styles should be written using objects.", "3"] [0, 0, 0, "Styles should be written using objects.", "3"]
], ],
"public/app/features/search/hooks/useSearchKeyboardSelection.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/search/page/components/ActionRow.tsx:5381": [ "public/app/features/search/page/components/ActionRow.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"] [0, 0, 0, "Styles should be written using objects.", "1"]
@ -5179,9 +5158,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"] [0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/features/users/state/reducers.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/variables/adapters.ts:5381": [ "public/app/features/variables/adapters.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"],
@ -5202,9 +5178,6 @@ exports[`better eslint`] = {
"public/app/features/variables/datasource/actions.ts:5381": [ "public/app/features/variables/datasource/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/variables/datasource/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/variables/editor/LegacyVariableQueryEditor.tsx:5381": [ "public/app/features/variables/editor/LegacyVariableQueryEditor.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", "0"]
], ],
@ -5286,9 +5259,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"] [0, 0, 0, "Unexpected any. Specify a different type.", "9"]
], ],
"public/app/features/variables/interval/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/variables/pickers/OptionsPicker/actions.ts:5381": [ "public/app/features/variables/pickers/OptionsPicker/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"]
@ -5370,9 +5340,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/features/variables/query/reducer.ts:5381": [ "public/app/features/variables/query/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
], ],
"public/app/features/variables/query/variableQueryObserver.ts:5381": [ "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.", "0"],
@ -5585,22 +5554,22 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"], [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.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"], [0, 0, 0, "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.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"], [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.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"], [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.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"], [0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"], [0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"], [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.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"], [0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"], [0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"], [0, 0, 0, "Unexpected any. Specify a different type.", "23"],
@ -5613,9 +5582,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "30"], [0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Unexpected any. Specify a different type.", "31"], [0, 0, 0, "Unexpected any. Specify a different type.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"], [0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"], [0, 0, 0, "Unexpected any. Specify a different type.", "33"]
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"]
], ],
"public/app/plugins/datasource/elasticsearch/LanguageProvider.ts:5381": [ "public/app/plugins/datasource/elasticsearch/LanguageProvider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5726,12 +5693,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "2"] [0, 0, 0, "Styles should be written using objects.", "2"]
], ],
"public/app/plugins/datasource/elasticsearch/datasource.ts:5381": [ "public/app/plugins/datasource/elasticsearch/datasource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"]
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
], ],
"public/app/plugins/datasource/elasticsearch/hooks/useStatelessReducer.ts:5381": [ "public/app/plugins/datasource/elasticsearch/hooks/useStatelessReducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [0, 0, 0, "Do not use any type assertions.", "0"]
@ -5757,9 +5723,8 @@ exports[`better eslint`] = {
], ],
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationQueryEditor.tsx:5381": [ "public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationQueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx:5381": [ "public/app/plugins/datasource/grafana-testdata-datasource/components/SimulationSchemaForm.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -6147,9 +6112,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "10"], [0, 0, 0, "Styles should be written using objects.", "10"],
[0, 0, 0, "Styles should be written using objects.", "11"], [0, 0, 0, "Styles should be written using objects.", "11"],
[0, 0, 0, "Styles should be written using objects.", "12"], [0, 0, 0, "Styles should be written using objects.", "12"],
[0, 0, 0, "Styles should be written using objects.", "13"], [0, 0, 0, "Styles should be written using objects.", "13"]
[0, 0, 0, "Do not use any type assertions.", "14"],
[0, 0, 0, "Do not use any type assertions.", "15"]
], ],
"public/app/plugins/datasource/loki/components/LokiOptionFields.tsx:5381": [ "public/app/plugins/datasource/loki/components/LokiOptionFields.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],
@ -6411,20 +6374,12 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"], [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.", "4"]
[0, 0, 0, "Do not use any type assertions.", "5"]
], ],
"public/app/plugins/datasource/prometheus/language_utils.ts:5381": [ "public/app/plugins/datasource/prometheus/language_utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [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.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"]
], ],
"public/app/plugins/datasource/prometheus/metric_find_query.test.ts:5381": [ "public/app/plugins/datasource/prometheus/metric_find_query.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -6610,9 +6565,8 @@ exports[`better eslint`] = {
], ],
"public/app/plugins/datasource/tempo/ServiceGraphSection.tsx:5381": [ "public/app/plugins/datasource/tempo/ServiceGraphSection.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Styles should be written using objects.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"], [0, 0, 0, "Styles should be written using objects.", "2"]
[0, 0, 0, "Styles should be written using objects.", "3"]
], ],
"public/app/plugins/datasource/tempo/configuration/ConfigEditor.tsx:5381": [ "public/app/plugins/datasource/tempo/configuration/ConfigEditor.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"] [0, 0, 0, "Styles should be written using objects.", "0"]
@ -6652,10 +6606,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "6"], [0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"], [0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"], [0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"], [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.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"]
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
], ],
"public/app/plugins/datasource/tempo/language_provider.ts:5381": [ "public/app/plugins/datasource/tempo/language_provider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]

View File

@ -4,8 +4,8 @@ import { DataSourceSrv } from '@grafana/runtime';
export const getDefaultCondition = () => ({ export const getDefaultCondition = () => ({
type: 'query', type: 'query',
query: { params: ['A', '5m', 'now'] }, query: { params: ['A', '5m', 'now'] },
reducer: { type: 'avg', params: [] as any[] }, reducer: { type: 'avg', params: [] },
evaluator: { type: 'gt', params: [null] as any[] }, evaluator: { type: 'gt', params: [null] },
operator: { type: 'and' }, operator: { type: 'and' },
}); });

View File

@ -177,7 +177,7 @@ export function ReceiverForm<R extends ChannelValues>({
type="button" type="button"
icon="plus" icon="plus"
variant="secondary" variant="secondary"
onClick={() => append({ ...defaultItem, __id: String(Math.random()) } as R)} onClick={() => append({ ...defaultItem, __id: String(Math.random()) })}
> >
Add contact point integration Add contact point integration
</Button> </Button>

View File

@ -41,7 +41,7 @@ export const OptionField: FC<Props> = ({
readOnly={readOnly} readOnly={readOnly}
defaultValue={defaultValue} defaultValue={defaultValue}
option={option} option={option}
errors={error as DeepMap<any, FieldError> | undefined} errors={error}
pathPrefix={optionPath} pathPrefix={optionPath}
/> />
); );

View File

@ -171,8 +171,7 @@ export function getFirstActiveAt(promRule?: AlertingRule) {
return null; return null;
} }
return promRule.alerts.reduce<Date | null>((prev, alert) => { return promRule.alerts.reduce<Date | null>((prev, alert) => {
const isNotNormal = const isNotNormal = mapStateWithReasonToBaseState(alert.state) !== GrafanaAlertState.Normal;
mapStateWithReasonToBaseState(alert.state as GrafanaAlertStateWithReason) !== GrafanaAlertState.Normal;
if (alert.activeAt && isNotNormal) { if (alert.activeAt && isNotNormal) {
const activeAt = new Date(alert.activeAt); const activeAt = new Date(alert.activeAt);
if (prev === null || prev.getTime() > activeAt.getTime()) { if (prev === null || prev.getTime() > activeAt.getTime()) {

View File

@ -71,11 +71,8 @@ export class DashboardGrid extends PureComponent<Props, State> {
if (e.payload.variable?.id === PANEL_FILTER_VARIABLE) { if (e.payload.variable?.id === PANEL_FILTER_VARIABLE) {
if ('current' in e.payload.variable) { if ('current' in e.payload.variable) {
let variable = e.payload.variable.current; let variable = e.payload.variable.current;
if ('value' in variable) { if ('value' in variable && typeof variable.value === 'string') {
let value = variable.value; this.setPanelFilter(variable.value);
if (typeof value === 'string') {
this.setPanelFilter(value as string);
}
} }
} }
} }

View File

@ -1,4 +1,4 @@
import { config, getBackendSrv, getGrafanaLiveSrv, setGrafanaLiveSrv } from '@grafana/runtime'; import { GrafanaLiveSrv, config, getBackendSrv, getGrafanaLiveSrv, setGrafanaLiveSrv } from '@grafana/runtime';
import { liveTimer } from 'app/features/dashboard/dashgrid/liveTimer'; import { liveTimer } from 'app/features/dashboard/dashgrid/liveTimer';
import { contextSrv } from '../../core/services/context_srv'; import { contextSrv } from '../../core/services/context_srv';
@ -30,6 +30,6 @@ export function initGrafanaLive() {
); );
} }
export function getGrafanaLiveCentrifugeSrv() { export function getGrafanaLiveCentrifugeSrv(): GrafanaLiveSrv {
return getGrafanaLiveSrv() as GrafanaLiveService; return getGrafanaLiveSrv();
} }

View File

@ -183,7 +183,7 @@ const enum Op {
MACROS = 'macros', MACROS = 'macros',
} }
// eslint-ignore // eslint-ignore
const customOperators = getCustomOperators(BasicConfig) as typeof BasicConfig.operators; const customOperators = getCustomOperators(BasicConfig);
const textWidget = BasicConfig.types.text.widgets.text; const textWidget = BasicConfig.types.text.widgets.text;
const opers = [...(textWidget.operators || []), Op.IN, Op.NOT_IN]; const opers = [...(textWidget.operators || []), Op.IN, Op.NOT_IN];
const customTextWidget = { const customTextWidget = {
@ -216,7 +216,7 @@ export const raqbConfig: Config = {
...BasicConfig, ...BasicConfig,
widgets, widgets,
settings, settings,
operators: customOperators as typeof BasicConfig.operators, operators: customOperators,
types: customTypes, types: customTypes,
}; };

View File

@ -85,8 +85,8 @@ export function useSearchKeyboardNavigation(
setHighlightIndex({ ...highlightIndexRef.current }); setHighlightIndex({ ...highlightIndexRef.current });
break; break;
} }
const url = urlsRef.current.values?.[idx] as string; const url: unknown = urlsRef.current.values?.[idx];
if (url) { if (typeof url === 'string') {
locationService.push(locationUtil.stripBaseFromUrl(url)); locationService.push(locationUtil.stripBaseFromUrl(url));
} }
} }

View File

@ -4,7 +4,7 @@ import config from 'app/core/config';
import { OrgUser, UsersState } from 'app/types'; import { OrgUser, UsersState } from 'app/types';
export const initialState: UsersState = { export const initialState: UsersState = {
users: [] as OrgUser[], users: [],
searchQuery: '', searchQuery: '',
page: 0, page: 0,
perPage: 30, perPage: 30,

View File

@ -10,7 +10,7 @@ import { DataSourceVariableModel, initialVariableModelState, VariableOption, Var
export const initialDataSourceVariableModelState: DataSourceVariableModel = { export const initialDataSourceVariableModelState: DataSourceVariableModel = {
...initialVariableModelState, ...initialVariableModelState,
type: 'datasource', type: 'datasource',
current: {} as VariableOption, current: {},
regex: '', regex: '',
options: [], options: [],
query: '', query: '',

View File

@ -14,7 +14,7 @@ export const initialIntervalVariableModelState: IntervalVariableModel = {
auto: false, auto: false,
query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d', query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d',
refresh: VariableRefresh.onTimeRangeChanged, refresh: VariableRefresh.onTimeRangeChanged,
current: {} as VariableOption, current: {},
}; };
export const intervalVariableSlice = createSlice({ export const intervalVariableSlice = createSlice({

View File

@ -25,7 +25,7 @@ export const initialQueryVariableModelState: QueryVariableModel = {
includeAll: false, includeAll: false,
allValue: null, allValue: null,
options: [], options: [],
current: {} as VariableOption, current: {},
definition: '', definition: '',
}; };

View File

@ -84,7 +84,7 @@ export class ElasticResponse {
} }
case 'extended_stats': { case 'extended_stats': {
for (const statName in metric.meta) { for (const statName in metric.meta) {
if (!metric.meta[statName as ExtendedStatMetaType]) { if (!metric.meta[statName]) {
continue; continue;
} }
@ -210,7 +210,7 @@ export class ElasticResponse {
} }
case 'extended_stats': { case 'extended_stats': {
for (const statName in metric.meta) { for (const statName in metric.meta) {
if (!metric.meta[statName as ExtendedStatMetaType]) { if (!metric.meta[statName]) {
continue; continue;
} }

View File

@ -134,7 +134,7 @@ export class ElasticDatasource
this.url = instanceSettings.url!; this.url = instanceSettings.url!;
this.name = instanceSettings.name; this.name = instanceSettings.name;
this.isProxyAccess = instanceSettings.access === 'proxy'; this.isProxyAccess = instanceSettings.access === 'proxy';
const settingsData = instanceSettings.jsonData || ({} as ElasticsearchOptions); const settingsData = instanceSettings.jsonData || {};
this.index = settingsData.index ?? instanceSettings.database ?? ''; this.index = settingsData.index ?? instanceSettings.database ?? '';
this.timeField = settingsData.timeField; this.timeField = settingsData.timeField;

View File

@ -25,7 +25,7 @@ interface SimInfo {
export const SimulationQueryEditor = ({ onChange, query, ds }: EditorProps) => { export const SimulationQueryEditor = ({ onChange, query, ds }: EditorProps) => {
const simQuery = query.sim ?? ({} as SimulationQuery); const simQuery = query.sim ?? ({} as SimulationQuery);
const simKey = simQuery.key ?? ({} as typeof simQuery.key); const simKey = simQuery.key ?? {};
// keep track of updated config state to pass down to form // keep track of updated config state to pass down to form
const [cfgValue, setCfgValue] = useState<Record<string, any>>({}); const [cfgValue, setCfgValue] = useState<Record<string, any>>({});

View File

@ -188,7 +188,7 @@ const getStyles = (theme: GrafanaTheme2) => ({
export class UnthemedLokiLabelBrowser extends React.Component<BrowserProps, BrowserState> { export class UnthemedLokiLabelBrowser extends React.Component<BrowserProps, BrowserState> {
state: BrowserState = { state: BrowserState = {
labels: [] as SelectableLabel[], labels: [],
searchTerm: '', searchTerm: '',
status: 'Ready', status: 'Ready',
error: '', error: '',
@ -497,7 +497,7 @@ export class UnthemedLokiLabelBrowser extends React.Component<BrowserProps, Brow
height={200} height={200}
itemCount={label.values?.length || 0} itemCount={label.values?.length || 0}
itemSize={28} itemSize={28}
itemKey={(i) => (label.values as FacettableValue[])[i].name} itemKey={(i) => label.values?.[i].name ?? i}
width={200} width={200}
className={styles.valueList} className={styles.valueList}
> >

View File

@ -348,9 +348,10 @@ export default class PromQlLanguageProvider extends LanguageProvider {
function getNameLabelValue(promQuery: string, tokens: any): string { function getNameLabelValue(promQuery: string, tokens: any): string {
let nameLabelValue = ''; let nameLabelValue = '';
for (let prop in tokens) {
if (typeof tokens[prop] === 'string') { for (const token of tokens) {
nameLabelValue = tokens[prop] as string; if (typeof token === 'string') {
nameLabelValue = token;
break; break;
} }
} }

View File

@ -287,6 +287,7 @@ const FromPromLikeMap: Record<string, AbstractLabelOperator> = {
'=~': AbstractLabelOperator.EqualRegEx, '=~': AbstractLabelOperator.EqualRegEx,
'!~': AbstractLabelOperator.NotEqualRegEx, '!~': AbstractLabelOperator.NotEqualRegEx,
}; };
const ToPromLikeMap: Record<AbstractLabelOperator, string> = invert(FromPromLikeMap) as Record< const ToPromLikeMap: Record<AbstractLabelOperator, string> = invert(FromPromLikeMap) as Record<
AbstractLabelOperator, AbstractLabelOperator,
string string
@ -321,31 +322,43 @@ export interface PromLikeQuery extends DataQuery {
range: boolean; range: boolean;
} }
function getMaybeTokenStringContent(token: Token): string {
if (typeof token.content === 'string') {
return token.content;
}
return '';
}
export function extractLabelMatchers(tokens: Array<string | Token>): AbstractLabelMatcher[] { export function extractLabelMatchers(tokens: Array<string | Token>): AbstractLabelMatcher[] {
const labelMatchers: AbstractLabelMatcher[] = []; const labelMatchers: AbstractLabelMatcher[] = [];
for (let prop in tokens) { for (const token of tokens) {
if (tokens[prop] instanceof Token) { if (!(token instanceof Token)) {
let token: Token = tokens[prop] as Token; continue;
}
if (token.type === 'context-labels') { if (token.type === 'context-labels') {
let labelKey = ''; let labelKey = '';
let labelValue = ''; let labelValue = '';
let labelOperator = ''; let labelOperator = '';
let contentTokens: any[] = token.content as any[];
for (let currentToken in contentTokens) { const contentTokens = Array.isArray(token.content) ? token.content : [token.content];
if (typeof contentTokens[currentToken] === 'string') {
for (let currentToken of contentTokens) {
if (typeof currentToken === 'string') {
let currentStr: string; let currentStr: string;
currentStr = contentTokens[currentToken] as string; currentStr = currentToken;
if (currentStr === '=' || currentStr === '!=' || currentStr === '=~' || currentStr === '!~') { if (currentStr === '=' || currentStr === '!=' || currentStr === '=~' || currentStr === '!~') {
labelOperator = currentStr; labelOperator = currentStr;
} }
} else if (contentTokens[currentToken] instanceof Token) { } else if (currentToken instanceof Token) {
switch (contentTokens[currentToken].type) { switch (currentToken.type) {
case 'label-key': case 'label-key':
labelKey = contentTokens[currentToken].content as string; labelKey = getMaybeTokenStringContent(currentToken);
break; break;
case 'label-value': case 'label-value':
labelValue = contentTokens[currentToken].content as string; labelValue = getMaybeTokenStringContent(currentToken);
labelValue = labelValue.substring(1, labelValue.length - 1); labelValue = labelValue.substring(1, labelValue.length - 1);
const labelComparator = FromPromLikeMap[labelOperator]; const labelComparator = FromPromLikeMap[labelOperator];
if (labelComparator) { if (labelComparator) {
@ -357,7 +370,6 @@ export function extractLabelMatchers(tokens: Array<string | Token>): AbstractLab
} }
} }
} }
}
return labelMatchers; return labelMatchers;
} }

View File

@ -50,7 +50,7 @@ export function ServiceGraphSection({
return null; return null;
} }
const ds = dsState.value as PrometheusDatasource; const ds = dsState.value;
if (!graphDatasourceUid) { if (!graphDatasourceUid) {
return getWarning( return getWarning(

View File

@ -986,7 +986,7 @@ function makePromLink(title: string, expr: string, datasourceUid: string, instan
range: !instant, range: !instant,
exemplar: !instant, exemplar: !instant,
instant: instant, instant: instant,
} as PromQuery, },
datasourceUid, datasourceUid,
datasourceName: getDatasourceSrv().getDataSourceSettingsByUid(datasourceUid)?.name ?? '', datasourceName: getDatasourceSrv().getDataSourceSettingsByUid(datasourceUid)?.name ?? '',
}, },