Skip to content

Commit

Permalink
redux types: Tighten ThunkAction to give just PerAccountState!
Browse files Browse the repository at this point in the history
This confirms that we've now explicitly marked global all the places
that we need a GlobalDispatch.  Anywhere that's still getting a
plain Dispatch -- which means the bulk of our thunk actions and
Redux components -- has to actually behave as per-account, modulo
any explicit fixmes.  (And we've only added one of those, a call to
assumeSecretlyGlobalState in eventActions.js.)
  • Loading branch information
gnprice committed Oct 26, 2021
1 parent 9e6695e commit 8f4347a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/reduxTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@ export interface Dispatch {
}

/** A per-account thunk action returning T. */
// TODO(#5006): use PerAccountState
export type ThunkAction<T> = (Dispatch, () => GlobalState, ThunkExtras) => T;
export type ThunkAction<T> = (Dispatch, () => PerAccountState, ThunkExtras) => T;

/** The Redux `dispatch` for a global context. */
export interface GlobalDispatch {
Expand All @@ -547,6 +546,9 @@ export type GlobalThunkAction<T> = (
// usable as a plain Dispatch, and a ThunkAction as a GlobalThunkAction.
(d: GlobalDispatch): Dispatch => d; // TODO(#5006)
<T>(a: ThunkAction<T>): GlobalThunkAction<T> => a; // TODO(#5006)
// And for *right* now, we allow the reverse, too.
(d: Dispatch): GlobalDispatch => d; // TODO(#5006)
<T>(a: GlobalThunkAction<T>): ThunkAction<T> => a; // TODO(#5006)
// But we don't allow the reverse.
// $FlowExpectedError[incompatible-return]
(d: Dispatch): GlobalDispatch => d;
// $FlowExpectedError[incompatible-exact]
// $FlowExpectedError[prop-missing]
<T>(a: GlobalThunkAction<T>): ThunkAction<T> => a;

0 comments on commit 8f4347a

Please sign in to comment.