Skip to content

Commit 3452dbe

Browse files
committed
type fix
1 parent de2d035 commit 3452dbe

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

public/app/core/reducers/fn-slice.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export interface FnGlobalState {
1717
hiddenVariables: string[];
1818
}
1919

20+
export type UpdateFNGlobalStateAction = PayloadAction<{
21+
type: keyof FnGlobalState;
22+
payload: FnGlobalState[keyof FnGlobalState];
23+
}>;
24+
2025
const INITIAL_MODE = GrafanaThemeType.Light;
2126

2227
const initialState: FnGlobalState = {
@@ -34,13 +39,10 @@ const fnSlice = createSlice({
3439
name: 'fnGlobalState',
3540
initialState,
3641
reducers: {
37-
setInitialMountState: (state, action: PayloadAction<Omit<FnGlobalState, "hiddenVariables">>) => {
42+
setInitialMountState: (state, action: PayloadAction<Omit<FnGlobalState, 'hiddenVariables'>>) => {
3843
return { ...state, ...action.payload };
3944
},
40-
updateFnState: (
41-
state: WritableDraft<FnGlobalState>,
42-
action: PayloadAction<{ type: keyof FnGlobalState; payload: FnGlobalState[keyof FnGlobalState] }>
43-
) => {
45+
updateFnState: (state: WritableDraft<FnGlobalState>, action: UpdateFNGlobalStateAction) => {
4446
const { type, payload } = action.payload;
4547

4648
return {
@@ -54,14 +56,14 @@ const fnSlice = createSlice({
5456
export const { updateFnState, setInitialMountState } = fnSlice.actions;
5557
export const fnSliceReducer = fnSlice.reducer;
5658

57-
export const updateFNGlobalState =
58-
(
59-
type: keyof FnGlobalState,
60-
payload: string | boolean | AnyObject<string, any> | string[] | null
61-
) =>
62-
{
63-
dispatch(updateFnState({
64-
type,
65-
payload,
66-
}));
67-
}
59+
export const updateFNGlobalState = (
60+
type: keyof FnGlobalState,
61+
payload: UpdateFNGlobalStateAction['payload']['payload']
62+
): void => {
63+
dispatch(
64+
updateFnState({
65+
type,
66+
payload,
67+
})
68+
);
69+
};

0 commit comments

Comments
 (0)