Skip to content

it's possible to return an array in catchError() #7460

Closed
@haexyh

Description

@haexyh

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

https://codesandbox.io/p/devbox/catcherror-issue-ld2pd7?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522cluaw6to000073b6lc47k8wmr%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522cluaw6to000023b6lvkv3v5ag%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522cluaw6to000043b6lqg5dww1y%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522cluaw6to000063b6lo6ueuwrr%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522cluaw6to000023b6lvkv3v5ag%2522%253A%257B%2522id%2522%253A%2522cluaw6to000023b6lvkv3v5ag%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522cluaw6to000063b6lo6ueuwrr%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cluaw6to000053b6lq544m71b%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A5173%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522cluaw6to000063b6lo6ueuwrr%2522%252C%2522activeTabId%2522%253A%2522cluaw6to000053b6lq544m71b%2522%257D%252C%2522cluaw6to000043b6lqg5dww1y%2522%253A%257B%2522id%2522%253A%2522cluaw6to000043b6lqg5dww1y%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cluaw6to000033b6lnuuh5tgl%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%255D%252C%2522activeTabId%2522%253A%2522cluaw6to000033b6lnuuh5tgl%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Version

7.8.1

Environment

osx: 13.6.3 (22G436)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions