Closed brunoti closed 4 years ago
Hey @brunoti,
When declaring async actions there are 2 typing styles, please make sure to not use both of them. Here are example docs: #143
Basically try this:
export const renew = createAsyncAction(
['USER/AUTH/RENEW', (): RequestPayload => ({
client: 'user',
request: {
method: 'POST',
url: '/renew',
},
})],
['USER/AUTH/RENEW_SUCCESS', (response: AxiosResponse<LoginResponse>): AxiosResponse<LoginResponse> => response],
['USER/AUTH/RENEW_FAIL', (error: AxiosError): AxiosError => error],
)();
Please do the same with all async actions respectively.
That worked! I got confused between docs in the beginning. That plus tutorials got me to the wrong path.
Yes it's confusing right now I agree, I have to work on it.
Description
I'm receiving a type error when using two async actions on one reducer:
Mandatory info
createReducer
?declare module 'typesafe-actions' { export type Store = StateType<typeof import('./index').store>; export type RootState = StateType<typeof import('./root-reducer').reducer>; export type RootAction = ActionType<typeof import('./root-action')>;
interface Types { RootAction: RootAction; } }
./app/store ├── clients.ts ├── index.ts ├── root-action.ts ├── root-reducer.ts └── types.d.ts
./app/basket/store ├── actions.ts ├── order │ ├── actions.ts │ └── reducer.ts ├── product │ ├── actions.ts │ └── reducer.ts ├── reducer.ts └── search ├── actions.ts └── reducer.ts ./app/user/store ├── actions.ts ├── auth │ ├── actions.ts │ ├── reducer.ts │ └── thunks.ts ├── permission │ ├── actions.ts │ └── reducer.ts └── reducer.ts
My async actions (./app/user/store/auth):
The action the error cites as conflict (./app/user/store/permissions/actions.ts):
Expected behavior
No type error there, since everything was ok until I added the renew handlers on this reducer. I've tried a lot of stuff, changing types, removing that other action but the error just changes the message and never goes away.
Suggested solution(s)
I really don't know. But if I can help in any way, just say. I'm sorry I couldn't put a codesandbox link. I'm using ReactNative and I found it very hard to recreate the same environment on codesandbox.
Project Dependencies
Environment (optional)