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

Types: forkJoin(any) and combineLatest(any) return the wrong thing #6226

Closed
benlesh opened this issue Apr 14, 2021 · 0 comments · Fixed by #6227
Closed

Types: forkJoin(any) and combineLatest(any) return the wrong thing #6226

benlesh opened this issue Apr 14, 2021 · 0 comments · Fixed by #6227

Comments

@benlesh
Copy link
Member

benlesh commented Apr 14, 2021

// FAIL: Gives us Observable<{ [key: string]: unknown }>
const source1 = forkJoin([of(1), of(2)] as any); // $ExpectType Observable<unknown>

// FAIL: Gives us Observable<{ [key: string]: unknown }>
const source2 = combineLatest([of(1), of(2)] as any); // $ExpectType Observable<unknown>

Basically, if we get an any to either one of these, we have no way of knowing if we're getting back an array or an object, so we need to return unknown.

benlesh added a commit to benlesh/rxjs that referenced this issue Apr 14, 2021
benlesh added a commit that referenced this issue Apr 15, 2021
…6227)

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

Resolves #6226

* chore: make shenanigans readonly

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* chore: Ensure there is no way the arg should work

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

* refactor: Move any catcher signatures up

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
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 a pull request may close this issue.

1 participant