Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Make getState generic for createThunkAction (#77615)

Nick Fitzpatrick6e6bca18d017
diff --git a/enterprise/frontend/src/metabase-enterprise/application_permissions/reducer.ts b/enterprise/frontend/src/metabase-enterprise/application_permissions/reducer.ts
index b6c95faf6c8..d315c716b82 100644
--- a/enterprise/frontend/src/metabase-enterprise/application_permissions/reducer.ts
+++ b/enterprise/frontend/src/metabase-enterprise/application_permissions/reducer.ts
@@ -79,12 +79,9 @@ const SAVE_APPLICATION_PERMISSIONS =
"metabase-enterprise/general-permissions/data/SAVE_APPLICATION_PERMISSIONS";
export const saveApplicationPermissions = createThunkAction(
SAVE_APPLICATION_PERMISSIONS,
- () => async (dispatch, getState) => {
- // getState() is typed as the base State, which doesn't include the
- // enterprise plugin slice this reducer registers at runtime.
- const { applicationPermissions, applicationPermissionsRevision } = (
- getState() as ApplicationPermissionsState
- ).plugins.applicationPermissionsPlugin;
+ () => async (dispatch, getState: () => ApplicationPermissionsState) => {
+ const { applicationPermissions, applicationPermissionsRevision } =
+ getState().plugins.applicationPermissionsPlugin;
const result = await runRtkEndpoint(
{
diff --git a/frontend/src/metabase/redux/utils.ts b/frontend/src/metabase/redux/utils.ts
index 8ac4f5cff14..90980841783 100644
--- a/frontend/src/metabase/redux/utils.ts
+++ b/frontend/src/metabase/redux/utils.ts
@@ -21,11 +21,15 @@ export function createThunkAction<
TArgs extends any[],
TResult,
TActionType extends string,
+ TState = State,
>(
actionType: TActionType,
thunkCreator: (
...args: TArgs
- ) => (dispatch: ThunkDispatch<any, any, any>, getState: GetState) => TResult,
+ ) => (
+ dispatch: ThunkDispatch<any, any, any>,
+ getState: () => TState,
+ ) => TResult,
): (
...args: TArgs
) => (