You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function reducer(state, action: Action) {
if(action instanceof ActionOne) {
action.one; // works
action.two; // error
} else if (action instanceof ActionTwo) {
action.one; // error
action.two; // works
} else {
return state;
}
}
Thank to these changes and to type guard feature I have intellisense and type checking inside of each if/else body.
The only problem with this solution is that dispatch method checks if the action object is the plain object which in my case is not true.
The text was updated successfully, but these errors were encountered:
I'm writing a react/redux project in TypeScript and I would like to have a little different structure of actions and reducers.
Here is the example:
and my reducer method
Thank to these changes and to type guard feature I have intellisense and type checking inside of each if/else body.
The only problem with this solution is that dispatch method checks if the action object is the plain object which in my case is not true.
The text was updated successfully, but these errors were encountered: