As it turned out your way of doing the combine reducers also works for type-safe all you gotta do is use type assertion ie:
const mainReducer = ({ products, shoppingCart }: InitialStateType, action: ProductActions | ShoppingCartActions) => ({ products: productReducer(products, action as ProductActions), shoppingCart: shoppingCartReducer(shoppingCart, action as ShoppingCartActions), });
By using the 'as' keyword there you can now get rid of the unions type on the action arg of your reducers
Hey, you are right, type assertion works well in this case, it makes the code look cleaner without the union types.
Thanks a lot.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As it turned out your way of doing the combine reducers also works for type-safe all you gotta do is use type assertion ie:
By using the 'as' keyword there you can now get rid of the unions type on the action arg of your reducers
Hey, you are right, type assertion works well in this case, it makes the code look cleaner without the union types.
Thanks a lot.