fix: use better type assertion for initialAsyncRequestState (#42087) (#42137)

(cherry picked from commit ca7a62682e)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-11-23 19:28:15 +01:00
committed by GitHub
co-authored by Gilles De Mey
parent 33c6628c6a
commit 772ef1626f
3 changed files with 11 additions and 2 deletions
@@ -58,6 +58,10 @@ const AmRoutes: FC = () => {
useCleanup((state) => state.unifiedAlerting.saveAMConfig);
const handleSave = (data: Partial<FormAmRoute>) => {
if (!result) {
return;
}
const newData = formAmRouteToAmRoute(
alertManagerSourceName,
{
@@ -55,7 +55,7 @@ export default function AlertmanagerConfig(): JSX.Element {
const loading = isDeleting || isLoadingConfig || isSaving;
const onSubmit = (values: FormValues) => {
if (alertManagerSourceName) {
if (alertManagerSourceName && config) {
dispatch(
updateAlertManagerConfigAction({
newConfig: JSON.parse(values.configJSON),
@@ -13,8 +13,13 @@ export interface AsyncRequestState<T> {
requestId?: string;
}
export const initialAsyncRequestState: AsyncRequestState<any> = Object.freeze({
export const initialAsyncRequestState: Pick<
AsyncRequestState<undefined>,
'loading' | 'dispatched' | 'result' | 'error'
> = Object.freeze({
loading: false,
result: undefined,
error: undefined,
dispatched: false,
});