-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Partition operator example throws typescript error #4419
Comments
I have just found #4119, but I have got the same error in my local project using:
So now blame who? :D |
That error is the "correct" error. Partition isn't usable within pipe because it's not really an operator, for the reason I explained in 4119: Partition returns a UnaryFunction, not an OperatorFunction, and pipe only takes OperatorFunctions as arguments. It seems like partition was broken (at least when used in pipe) with the move to pipeable operators, but the clean up work to deprecate/replace it hasn't been priority as partition isn't that widely used. See these issues: So TS is right to complain about partition being used in pipe, but you can still use partition as a function in its own right, I believe. (and all the StackBlitz stuff in that thread is resolved now as far as I know, so StackBlitz is giving you an accurate error) |
Ok, so then examples should be fixed as they use partition as pipe now:
:) |
Partition should really have been a static function, and not an operator. That's the real solution here. And also updating the docs. TODO:
|
I'll grab this one if no one has started working on this? |
I wonder who made the statistics that tell that partition isn't widely used. I think there are valid scenarios where you want to have to safetly partitioned Observables where you know that they will never emit the same value. My current solution is really extremely ugly and verbose.
|
Hello, |
|
This has been resolved by providing a static import
const [evens$, odds$] = partition(of(1, 2, 3, 4, 5), n => x % 2 === 0); |
Documentation Related To Component:
partition operator
https://www.learnrxjs.io/operators/transformation/partition.html
https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/partition.ts
Please check those that apply
Description Of The Issue
Opening the example in Stackblitz we are getting typescript error:
typescript is not complaining about this usage:
Result is the same.
I did not check other example or other online editors but IMHO it would be the same.
I do not have more time for making PR, also I am not sure about whether implementation should be fixed not to confuse typescript or syntax in examples should follow the usage I have provided here.
Sorry.
Thank you for your time and happy coding :)
EDIT:
I have just check jsBin and jsFiddle. I have find out that they are not relevant as they does not support typescript errors. I have tested
const num: Number = 'text';
and they both did not complain at all.The text was updated successfully, but these errors were encountered: