-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
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
Using Redux Sagas with Typescript 4.2 & above #2251
Comments
You can try out typed-redux-saga that will provide better Typescript typings for |
Typing multiple There is an outstanding issue discussing this in-depth: microsoft/TypeScript#43632 Typing For all those const allActionValidationConfig: TheExpectedValue = yield select(getAllActionValidationConfig); For the generator return type, there is a import { SagaIterator } from 'redux-saga';
// where RT is the return type
function* evaluateTreeSaga(): SagaIterator<RT> {
// ...
} |
Thanks a lot for your time and inputs @neurosnap @JabbyPanda. I did use the function *validateResponse(): SagaIterator<boolean>{}
// It throws an error saying yield returns any
const isValidResponse = yield validateResponse();
// I need to do the following
const isValidResponse: boolean = yield validateResponse(); Not that important but I had to type |
If you have anymore follow up questions, please feel free to ask! |
Sorry to ressurect this issue @neurosnap, but I have the same problem @yaldram mentioned. Using this as the return type of the saga: Appears to have no effect on the return type from the caller: // below is an `any` type
const newPasswordGrantToken = yield call(requireNewPasswordGrantToken); See below for typescript error. I'm using |
@kirgy yes you have to manually type the yields unfortunately. We are doing the same in our code base. |
That's right. Also, that error in particular is being raised because the saga that |
Description
We just updated typescript to typescript version 4.2 and we are getting a lot of errors. I read these following resources but these were very basic -
I need some help from the community how should I type a saga with multiple yield calls like in the below file
function *evaluateTreeSaga()
, it contains multiple yield calls.function * callApi
saga.Please help, thanks a lot.
The text was updated successfully, but these errors were encountered: