const subject = new Subject<void>();
subject.pipe(
scan((acc, curr) => acc + 1, 0)
).subscribe(count => console.log(count));
subject.next(); // should output 1
subject.next(); // should output 2
subject.next(); // should output 3
上面给出了以下编译器错误:
TS2345: Argument of type 'MonoTypeOperatorFunction<number>' is not
assignable to parameter of type 'OperatorFunction<void, number>'.
Types of parameters 'source' and 'source' are incompatible.
Type 'Observable<void>' is not assignable to type 'Observable<number>'.
Type 'void' is not assignable to type 'number'.