Hi there-
Issue: I am unable to pass a TypeScript Type for the meta object that an actionCreator produces.
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: 'd@d.com'}, {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: 'test@test.com'}, {info: true})
loginFunc(startAction)
startAction will throw a TypeScript error because its meta property has a different definition than that of LoginAction
My suggestion would be to add something like:
const logIn = actionCreator.async<LogInData, LogInResponseData, LogInErrorData, MetaData>('LOGIN');
Hi there-
Issue: I am unable to pass a TypeScript Type for the
metaobject that anactionCreatorproduces.Example:
I want to create async actions for an event "login":
I also want to pass data via the
metaobject 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:
startActionwill throw a TypeScript error because itsmetaproperty has a different definition than that ofLoginActionMy suggestion would be to add something like: