Skip to content
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

fix: forkJoin/combineLatest return Observable<unknown> if passed any #6227

Merged

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Apr 14, 2021

Resolves #6226

@benlesh benlesh requested a review from cartant April 14, 2021 22:46
src/internal/AnyCatcher.ts Outdated Show resolved Hide resolved
benlesh and others added 2 commits April 14, 2021 19:24
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
If the user passed that exact shape of object in AnyCatcher, technically it should work. This ensures there's no way it would work properly so `Observable<unknown>` is accurate.

Also adds some documentation to the areas
* an array or an object, so you're getting `unknown`. Use better types.
* @param arg Something typed as `any`
*/
export function combineLatest<T extends AnyCatcher>(arg: T): Observable<unknown>;
Copy link
Collaborator

@cartant cartant Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I would make this the first signature. IDK why any skips all of the signatures above this one and I would not like to rely upon that behaviour never changing. There should be no reason this signature cannot be the first.

Actually, I do know why, but I still think the weirdo, any-catcher signatures should be first - just in case someone adds an additional signature before it and effects different behaviour. The tests would break of, course, but it might not be immediately obvious why. I think the any-catcher sigs should go first and should be accompanied by a comment that explains why. Or at least says they should remain as the first-placed overload signatures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really good idea!

* an array or an object, so you're getting `unknown`. Use better types.
* @param arg Something typed as `any`
*/
export function forkJoin<T extends AnyCatcher>(arg: T): Observable<unknown>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Make this the first overload signature.

src/internal/AnyCatcher.ts Outdated Show resolved Hide resolved
@benlesh benlesh requested a review from cartant April 15, 2021 13:25
@benlesh benlesh merged commit ce0a2fa into ReactiveX:master Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types: forkJoin(any) and combineLatest(any) return the wrong thing
3 participants