![](/img/trans.png)
[英]The 'this' context of type '...' is not assignable to method's 'this' of type '...'
[英]RxJs pipe and lettable operator `map`: 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'
我有一个非常基本的例子,它使用来自rxjs@5.5
pipe
的rxjs@5.5
操作符map
:
import { map } from 'rxjs/operator/map';
let o = of(1, 2, 3, 4).pipe(
map((v) => v * 2)
);
但它会产生错误Error:(34, 5) TS2684:The 'this' context of type 'void' is not assignable to method's 'this' of type 'Observable<{}>'.
这有什么问题?
应该从rxjs/operators
导入lettable实例运算rxjs/operators
:
import { map } from 'rxjs/operators';
与从rxjs/operator
导入的非可释放等价物相反:
import { map } from 'rxjs/operator/map';
要了解有关lettable operator read的更多信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.