it's possible to return an array in catchError()
haexyh opened this issue · 2 comments
haexyh commented
Describe the bug
I have discovered that it's possible to return an array in catchError.
Expected behavior
Returning arrays shouldn't be possible.
catchError(() => [])
Reproduction code
import { tap, switchMap, throwError, catchError, of } from "rxjs";
of(1)
.pipe(
tap(console.log),
switchMap(() => throwError(() => new Error())),
catchError(() => []),
)
.subscribe(console.log);
Reproduction URL
Version
7.8.1
Environment
osx: 13.6.3 (22G436)
Additional context
No response
haexyh commented
The issue can be closed, I recognize that this is a feature. An '[]' is ArrayLike
jakovljevic-mladen commented
Indeed, it is a feature. It is designed to cover anything that can be converted to an Observable.
The interface for this operator is ObservableInput which includes ArrayLike
- arrays can be converted to Observables.
Closing as requested.