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
The following typing triggers an error in the reducerFails reducer where we access the action.type after a destructuring operation. Flow should apply the same logic as it does for the case in reducerPasses.
typeAction=|{type: 'FOO'}|{type: 'BAR',payload: {}};functionreducerPasses(action: Action){if(action.type==='BAR'){return{ ...action.payload};}returnaction;}functionreducerFails(action: Action){const{ type }=action;if(type==='BAR'){return{ ...action.payload};}returnaction;}
It's weird that Flow can not make the connection between the desctructured type and action.type and figure out what action is at that point.
But if this is the intended use case for disjoint unions and refinements, at least this can be highlighted in the docs section for disjoint unions (I can't find any mention of this requirement), in order to not confuse other folks. @vkurchatkin what do you think?
The following typing triggers an error in the
reducerFails
reducer where we access theaction.type
after a destructuring operation. Flow should apply the same logic as it does for the case inreducerPasses
.See example code
Reference docs: https://flow.org/en/docs/types/unions/#toc-disjoint-unions
The text was updated successfully, but these errors were encountered: