-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Description
Looking at the Typescript typings for Redux, it looks like there is no built-in way to type check calls to dispatch
, etc. This looks like something that could be improved. For example you could envisage a store definition that looks something like the following:
interface Store<S, A extends Action = Action> {
dispatch: Dispatch<S, A>;
getState(): S;
subscribe(listener: () => void): Unsubscribe;
}
export interface Dispatch<S, A extends Action = Action> {
(action: A): A;
}
Then, with appropriate modifications elsewhere, you could something like the following:
type MyAppActions =
| CreateTodo
| DeleteTodo
| UpdateTodo;
const store = createStore<MyAppState, MyAppActions>(myReducer);
I would be interested to hear what you think of this as an idea. In particular, is this an idea that has already been considered and rejected in the past?
Metadata
Metadata
Assignees
Labels
No labels