Skip to content

multiple using of tap() causes a false error #7498

Open
@its-dibo

Description

@its-dibo

Describe the bug

the following code is correct, but will generate a false error

import { Observable, of, tap } from 'rxjs';

let test$: Observable<number> = of(1).pipe(
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
  tap(() => 1),
);

Error:

Type 'Observable<unknown>' is not assignable to type 'Observable<number>'.
  Type 'unknown' is not assignable to type 'number'.ts(2322)

commenting any of tap() blocks causes the error to be disappeared.

also, explicitly set the type again resolves the error. but TS can infer the type easily

of(1).pipe( ... ) as Observable<number>

Expected behavior

no error

Reproduction code

No response

Reproduction URL

https://stackblitz.com/edit/rxjs-jvajmd?devtoolsheight=60&file=index.ts,tsconfig.json

Version

next

Environment

No response

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