ReactiveX / ReactiveX/rxjs

Type inference lost after 10 operators inside an observable pipe

Open
#5,599 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

TS
Dominant language
TypeScript
Stars
31.7k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Current Behavior

When creating a pipe of 10 operators, when you get to operator 10, you lose all type inference.

Reproduction

In this stackblitz, you can see there's no type error on the 10th line in the pipe.

This didn't always appear to be the case. Here's the exact same code, but using rxjs 6.2.0. It works as you would expect, you get an error on the line.

It looks 6.2.1 lost all type inference, and then 6.3.0 fixed it, but only for the first 9 operators.

Expected behavior

I would expect the 10th line to still have type inference.

Environment

  • Runtime: Node 12, Chrome 84.0.4147.89
  • RxJS version: 6.6.0

Additional context/Screenshots

It looks like it's explicitly defined this way, but obviously that's not ideal as it breaks all of our typescript if we have 10 pipe operators.

https://github.com/ReactiveX/rxjs/blob/master/src/internal/Observable.ts#L407

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/internal/Observable.ts around the referenced line 407 and compare the pipe type definitions with the RxJS 6.2.0, 6.3.0, and 6.6.0 behavior shown in the linked StackBlitz reproductions. Verify the change by ensuring type inference is retained for the 10th operator and that the expected type error appears there.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.