We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi there-
Issue: I am unable to pass a TypeScript Type for the meta object that an actionCreator produces.
meta
actionCreator
Example: I want to create async actions for an event "login":
interface LogInData { email: string } interface LogInResponseData { token: string } interface LogInErrorData { error: string } const logIn = actionCreator.async<LogInData, LogInResponseData, LogInErrorData>('LOGIN');
I also want to pass data via the meta object on the action.
dispatch(login.started({email: '[email protected]'}, {info: true}))
I now want to define what my action will look like, as well as create the saga:
import {Action} from 'redux'; interface LoginAction extends Action { meta: { info: boolean } } export function* loginFunc(action: LoginAction) { ...irrelevant } takeEvery(logIn.started,loginFunc),
The issue arises when you try to test the code:
const startAction = logIn.start({email: '[email protected]'}, {info: true}) loginFunc(startAction)
startAction will throw a TypeScript error because its meta property has a different definition than that of LoginAction
startAction
LoginAction
My suggestion would be to add something like:
const logIn = actionCreator.async<LogInData, LogInResponseData, LogInErrorData, MetaData>('LOGIN');
The text was updated successfully, but these errors were encountered:
This sounds good to me, especially since we can now use defaults for generic parameters, so this won't break existing code.
However, I don't really have much time to work on this now, but I'd happily accept PRs!
Sorry, something went wrong.
No branches or pull requests
Hi there-
Issue: I am unable to pass a TypeScript Type for the
meta
object that anactionCreator
produces.Example:
I want to create async actions for an event "login":
I also want to pass data via the
meta
object on the action.I now want to define what my action will look like, as well as create the saga:
The issue arises when you try to test the code:
startAction
will throw a TypeScript error because itsmeta
property has a different definition than that ofLoginAction
My suggestion would be to add something like:
The text was updated successfully, but these errors were encountered: