I have the following redux-thunk action:
import { Action } from "redux";
import { ThunkAction as ReduxThunkAction } from "redux-thunk";
import { IState } from "./store";
type TThunkAction = ReduxThunkAction<void, IState, unknown, Action<string>>;
export type TReturnValue = { someString: string };
export const someAction = (): TThunkAction => (dispatch): TReturnValue => ({
someString: "some value"
});
And I dispatch the action like this:
const { someString } = dispatch(someAction());
which throws the error,
const { someString } = dispatch(someAction());
^^^^^^^^^^
Property 'someString' does not exist on type 'TThunkAction<void, IState, unknown, Action<string>>'
I've tried casting the result like this,
const { someString } = dispatch<TReturnValue>(someAction());
And I've tried redefining TThunkAction, but nothing worked.
How can I get Typescript to know what type to expect from the dispatch action?