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
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>;
}
Closing, as this appears to be a dupe of the issue resolved in https://github.com/ReactiveX/rxjs/pull/4735
Most helpful comment
Closing, as this appears to be a dupe of the issue resolved in https://github.com/ReactiveX/rxjs/pull/4735