使用Angular 5.2,我收到此resharper打字稿错误: 无法转换类型'Observable< IPartBundle []>输入'Observable< IOrderHead>'
public orderHead$: Observable<IOrderHead>;
ngOnInit() {
this.orderHead$ = this.route.paramMap.switchMap((params: ParamMap) => {
this.partBundle$ = this.orderShipService.getPartBundleObservable(this.orderShipDetails$, this.cartons$, this.licensePlate, this.orderLine);
return this.order.getOrderHeadObservable(+params.get('orderNumber'));
}).share();
}
答案 0 :(得分:0)
似乎Resharper想要包含在share方法中的类型,就像这样。
this.orderHead$ = this.route.paramMap.switchMap((params: ParamMap) => {
this.partBundle$ =
this.orderShipService.getPartBundleObservable(this.orderShipDetails$,
this.cartons$, this.licensePlate, this.orderLine);
return this.order.getOrderHeadObservable(+params.get('orderNumber'));
}).share<IOrderHead>();
然后,resharper错误就消失了。