-
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
reduce operator typing gets lost #4086
Comments
tl;dr: I'm pretty sure this isn't a bug, and I think your code was getting around typechecking due to a bug in rxjs 6.2.1. I believe you need to be explicit about the types passed to reduce, and the following should type check and work correctly under rxjs 6.3.x+:
(change is Full explanation (disclaimer - I don't work on rxjs, I just enjoy figuring this stuff out and I could be wrong): I believe your code was getting around correct typing using the funky If you take your code under rxjs 6.2.2 and change it to:
You'll notice there's an error, because thingToReturn is an I think what's happening in 6.2.2 is something along the lines of:
In 6.3 the bad overload is gone, the inference doesn't happen even with the expression in the return, and TS errors because your reduce has type param In this case you need to tell TS explicitly that you are not using I'm not sure if there's anything that can be done in reduce.ts to allow TS to better infer when the two-type-param overload is wanted without the usage having to be specific. I don't think there is, but I could easily be missing something! |
@jgbpercy |
This has been addressed to the best of our ability in RxJS 7.0 |
Bug Report
Current Behavior
When using reduce/scan, typings get lost on 6.3.1 version of rxjs
Reproduction
https://stackblitz.com/edit/typescript-osxh4v
Expected behavior
It should not throw the typing error when trying to reduce.
Environment
The text was updated successfully, but these errors were encountered: