P
P
Pumba88972021-09-03 23:21:21
typescript
Pumba8897, 2021-09-03 23:21:21

How to type reducers?

Is there an easy way to type reducers that twitch not with actions, but with sagas? Now I type all actions with the help of this one. designs:

import * as actions from '../../actions';

type ActionsValueTypes<T> = T extends { [key: string]: infer K } ? K : never;

export type TratataActions = ReturnType<ActionsValueTypes<typeof actions>>


but there are reducers that twitch only from sagas in different places.
For example:
yield put({
            type: REQUEST_TRATATA_SUCCESS,
            data,
        });


It will not work to import them in one fell swoop. is there any way not to prescribe a type for each such reducer?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question