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
Cannot yield* a SagaIterator in TS 3.6+ #2079
Comments
@gilbsgilbs could you check this out? @angelsl keep in mind that the documentation is not written with TS in mind, so differences between what is possible when using plain JS and what is possible by default when using TS are somewhat expected. For instance, it's possible to just yield anything - for example a number, but types shouldn't quite allow this because it doesn't make much sense. There is little to no gain in using |
+1 on this I get that the documentation is not written for TS in mind, but I still think this is an error in the typings. For what it's worth, I just ran into a case where I needed to use |
I have same problem. As a temporary solution I have created this type which use Generator from lib.es2015.generator.d.ts. It is combination of Saga and SagaIterator types. In most cases my saga does not return any value, that is why return type is set to void by default. Generator type contains |
The documentation suggests that we can
yield*
a Saga to compose them.However, this isn't possible in TS 3.6+ if the yielded Saga is annotated as
SagaIterator
: https://codesandbox.io/s/dry-forest-gni5eThis is the type error:
For TS <= 3.5, this type definition is used, which makes it possible:
But for TS >= 3.6, this is used instead, which is no longer Iterable:
One can do this instead:
But it is not strictly the same.
Is the type definition wrong, or is the documentation wrong, or is this just a limitation due to the stricter generator checking in TS 3.6?
The text was updated successfully, but these errors were encountered: