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

Incorrect type signatures for concatAll and mergeAll operators #2759

Closed
kevgrasso opened this issue Jul 18, 2017 · 9 comments
Closed

Incorrect type signatures for concatAll and mergeAll operators #2759

kevgrasso opened this issue Jul 18, 2017 · 9 comments

Comments

@kevgrasso
Copy link

RxJS version:
5.4.2

Code to reproduce:

const fromEvent = Rx.Observable.fromEvent;
const mouseEvents = Rx.Observable.of([fromEvent(document, "click"), fromEvent(document, "mouseenter"), fromEvent(document, "mouseleave")]); 

mouseEvents.concatAll().mapTo(null);
mouseEvents.mergeAll().mapTo(null);

Expected behavior:
Code compiles without error.

Actual behavior:
Type error: "[ts] Property 'mapTo' does not exist on type 'Observable<{}>[]'.

Additional information:
Incorrect type signatures are-

function concatAll<T>(this: Observable<T>): T;
function concatAll<T, R>(this: Observable<T>): Subscribable<R>;

function mergeAll<T>(this: Observable<T>, concurrent?: number): T;
function mergeAll<T, R>(this: Observable<T>, concurrent?: number): Subscribable<R>;

They should be (I believe):

function concatAll<T extends ObservableInput<R>, R>(this: Observable<T>): Observable<R>;

function mergeAll<T extends ObservableInput<R>, R>(this: Observable<T>, concurrent?: number): Observable<R>;
@aboyton
Copy link

aboyton commented Aug 3, 2017

I ran into a similar problem myself today with similar code, trying

Observable.of([[1, 2, 3], [4, 5]]).mergeAll().subscribe(x => console.log(x));

This prints (see jsbin)

[1, 2, 3]
[4, 5]

The current definitions give me the compilation error [ts] Property 'subscribe' does not exist on type 'number[][]'. which seems wrong, but these new proposed definitions give me the final type of x to be (parameter) x: {} which also seems incorrect according to the values emitted on the console.

So the proposed definitions are definitely better and fix other uses of mergeAll in my code, I suspect that we need the following definition as well (before the one above to it's a higher preference).

function concatAll<T>(this: Observable<T[]>): Observable<T>;
function mergeAll<T>(this: Observable<T[]>, concurrent?: number): Observable<T>

aboyton pushed a commit to aboyton/rxjs that referenced this issue Aug 3, 2017
Change the type signatures for mergeAll and concatAll to be correct.
The previous signatures did not work for merging/concatenating an
observable of an array.

Fixes ReactiveX#2759
@kwonoj
Copy link
Member

kwonoj commented Aug 3, 2017

I'm feeling this is dupe to #2690 (and related issues) which we had fixes in next major.

@tvald
Copy link

tvald commented Aug 5, 2017

Can we please fix this without waiting for a major release? This is an active issue, with two separate PRs to (partially) fix it on master in the last month: #2779, #2760

The existing typings for mergeAll() are wrong and unusable. It should be trivial to drop in the correct typing from #2779: https://github.com/ReactiveX/rxjs/pull/2690/files#diff-287d1762ff7b138d92ddcb79627353f7

@aboyton
Copy link

aboyton commented Aug 14, 2017

Or at least do we have any timeframe on when the next major version is expected to be released? I agree, the current typings are pretty well unusable for me.

@kwonoj
Copy link
Member

kwonoj commented Aug 14, 2017

@aboyton Next major is already published as rxjs@6 alpha version, though it need to be published with latest changes. It won't be released as public soon enough cause we do expect to pick up some more breaking changes.

@simeyla
Copy link

simeyla commented Feb 1, 2018

Any reason why this was ever there in the first place. I don't see how 6 months later this wasn't ever fixed.
Was it an actual 'typo' or was there a reason it was wrong? And how do I even use concatAll() in my code?

It's confusing the heck out of me even after having found this thread.

@jdevng
Copy link

jdevng commented Feb 14, 2018

To @simeyla 's post, is verification assistance needed? Is there a write up on how to get started - I've never worked on github before, but I've designed asynchronous semiconductors and verified them. RxJS is cool, but github is a new concept to me.

@benlesh
Copy link
Member

benlesh commented Feb 20, 2018

Closed by #3321

@benlesh benlesh closed this as completed Feb 20, 2018
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants