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

6.5.x endWith() Regression #4751

Closed
dairyisscary opened this issue May 1, 2019 · 1 comment
Closed

6.5.x endWith() Regression #4751

dairyisscary opened this issue May 1, 2019 · 1 comment

Comments

@dairyisscary
Copy link

Bug Report

Current Behavior
endWith throws TypeError.

TypeError: You provided '2' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

Reproduction
https://jsfiddle.net/1Lz8m4bx/1/

 of(1).pipe(endWith(2)).subscribe(console.log);

Expected behavior
Should not throw :)

Environment

  • Runtime: Chrome latest
  • RxJS version: 6.5.1 (seems to be in 6.5.0 as well)

Possible Solution
After investigating a bit, I believe this line in the implementation of endWith isn't quite right:

// current implemention:
export function endWith<T>(...array: Array<T | SchedulerLike>): MonoTypeOperatorFunction<T> {
  return (source: Observable<T>) => concat(source, ...(array as any[])) as Observable<T>;
}

// Maybe something like this (I wouldn't be surprised if that allows the removal of the type assertion):
export function endWith<T>(...array: Array<T | SchedulerLike>): MonoTypeOperatorFunction<T> {
  return (source: Observable<T>) => concat(source, of(...array)) as Observable<T>;
}
@cartant
Copy link
Collaborator

cartant commented May 1, 2019

Closing, as this appears to be a dupe of the issue resolved in #4735

@cartant cartant closed this as completed May 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
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

2 participants