Subject: Property 'next' does not exist on type 'Observable<any>'. #6440
Replies: 1 comment 4 replies
-
This is what I think is happening. Hope it helps. The subject has next defined. Line 56 in f47425d The observable does not it, it works because the subject extends observable so you can use pipe which from a typing point of view has no knowledge of the subject type. Basically, the next prop is just being left on the observable after the pipe changes its type into an observable. I personally separate my input streams from my output streams, like read and write segregation. let input = new Subject();
let output = input.pipe(tap(console.log))
let output2 = output.pipe(tap(console.log))
output2.subscribe(console.log);
input.next('Hello World'); |
Beta Was this translation helpful? Give feedback.
-
This code runs as I expect but I get the following type error:
I can't imagine I'm the first person to notice this, but how should I take it?
It seems to me that
new Subject().pipe(...)
should return some typethat's like Observable but with
.next()
, or that.next()
should be privatehere (but why?).
Beta Was this translation helpful? Give feedback.
All reactions