-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
severest/retrobot
#221Labels
TSIssues and PRs related purely to TypeScript issuesIssues and PRs related purely to TypeScript issues
Description
Bug Report
Current Behavior
const input: Observable<number> = of(1, 2, 3)
const output = input.pipe(switchAll())
output.subscribe(value => console.log(value))No type error, but runtime error:
You provided '1' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
Reproduction
- REPL or Repo link: https://stackblitz.com/edit/typescript-zgtnbp
Expected behavior
This should give a type error like number is not assignable to ObservableInput<T>
Environment
- RxJS version: 6.2.1
Possible Solution
I tried a few things, but it seems like type inference just fails here. TypeScript needs to infer a type based on the usage of the return value here.
Workaround
Use switchMap(x => x) instead (switchMap(identity) also breaks inference)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
TSIssues and PRs related purely to TypeScript issuesIssues and PRs related purely to TypeScript issues