Closed Eljoy closed 2 years ago
The result type of createReducer is any instead of Reducer
any
Reducer
"typescript": "^4.2.4", "typesafe-actions": "^5.1.0",
Actions:
export const signIn = createAsyncAction( '[AUTH] SIGN_IN_REQUEST', '[AUTH] SIGN_IN_SUCCESS', '[AUTH] SIGN_IN_FAILURE' )<void, Entities.Token, Error>() export const signOut = createAsyncAction( '[AUTH] SIGN_OUT_REQUEST', '[AUTH] SIGN_OUT_SUCCESS', '[AUTH] SIGN_OUT_FAILURE' )<void, void, Error>()
// authReducer type = any const authReducer = createReducer<StateType>(initialState) .handleAction(signIn.success, () => ({ isSignedIn: true })) .handleAction(signOut.success, () => ({ isSignedIn: false }))
Temp solution: Setting type explicitly:
const authReducer: Reducer<StateType, RootStateOrAny> = createReducer<StateType>(initialState) .handleAction(signIn.success, () => ({ isSignedIn: true })) .handleAction(signOut.success, () => ({ isSignedIn: false }))
I think RootAction may help:
RootAction
And this Todo-App is a complete demo:
Seems like resolved
The result type of createReducer is
any
instead ofReducer
"typescript": "^4.2.4", "typesafe-actions": "^5.1.0",
Actions:
Reducer
Temp solution: Setting type explicitly: