【发布时间】:2023-03-23 00:16:01
【问题描述】:
RxJS 5.5.6。我正在尝试将Observable<string[]> 转换为Observable<string>
我不确定mergeAll 运算符是否是我正在寻找的
const o1: Observable<string[]> = of(['a', 'b', 'c']);
const o2: Observable<string> = o1.pipe(
mergeAll()
);
Typescript 将返回此错误:
Type 'Observable<string | string[]>' is not assignable to type 'Observable<string>'.
Type 'string | string[]' is not assignable to type 'string'.
Type 'string[]' is not assignable to type 'string'.
我接收 Observable 作为参数,我可以改变构造方式。
【问题讨论】:
标签: typescript rxjs rxjs5