any/type assertion fixes (#57009)

This commit is contained in:
Ashley Harrison
2022-10-17 10:10:10 +01:00
committed by GitHub
parent e25475b9c8
commit 3cca8e3676
27 changed files with 67 additions and 309 deletions

View File

@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import useAsyncFn from 'react-use/lib/useAsyncFn';
import { getBackendSrv } from '@grafana/runtime';
import { getBackendSrv, isFetchError } from '@grafana/runtime';
import { LinkButton } from '@grafana/ui';
import { Page } from 'app/core/components/Page/Page';
import { contextSrv } from 'app/core/services/context_srv';
@@ -17,8 +17,8 @@ const getOrgs = async () => {
return await getBackendSrv().get('/api/orgs');
};
const getErrorMessage = (error: any) => {
return error?.data?.message || 'An unexpected error happened.';
const getErrorMessage = (error: Error) => {
return isFetchError(error) ? error?.data?.message : 'An unexpected error happened.';
};
export default function AdminListOrgsPages() {

View File

@@ -7,10 +7,7 @@ import { Page } from 'app/core/components/Page/Page';
type Settings = { [key: string]: { [key: string]: string } };
function AdminSettings() {
const { loading, value: settings } = useAsync(
() => getBackendSrv().get('/api/admin/settings') as Promise<Settings>,
[]
);
const { loading, value: settings } = useAsync(() => getBackendSrv().get<Settings>('/api/admin/settings'), []);
return (
<Page navId="server-settings">

View File

@@ -24,7 +24,7 @@ import { changeFilter, changePage, changeQuery, fetchUsers } from './state/actio
export interface FilterProps {
filters: UserFilter[];
onChange: (filter: any) => void;
onChange: (filter: UserFilter) => void;
className?: string;
}
const extraFilters: Array<ComponentType<FilterProps>> = [];