Open danielnixon opened 4 years ago
@gilbsgilbs another one for you to ponder ☝️
If we ignore the function and array forms, something like this is what I'm doing (where MyAppActionType
is the union of all my app's action types):
import { take as rawTake } from "typed-redux-saga";
export const take = <A extends MyAppActionType>(
pattern: A["type"] | "*",
): SagaGenerator<"*" extends typeof pattern ? MyAppActionType : A, TakeEffect> =>
rawTake(pattern);
Consider when the take effect is passed a string and an action type param, like this:
In cases like this we should be able to constrain the passed string to
"FOO" | "*"
, giving some extra type safety.See https://redux-saga.js.org/docs/api/#takepattern