如何在保持输入正确的同时从Promise从RxJS 5迁移到RxJS 6?
RxJS 5,一切正常:
return Observable.fromPromise<SomeInterface>(somePromiseFn())
RxJS 6:
return from<SomeInterface>(somePromiseFn())
抱怨:
Type 'SomeInterface' does not satisfy the constraint 'ObservableInput<any>'.
Type 'SomeInterface' is not assignable to type 'ArrayLike<any>'.
因此,如果我理解正确,它期望from将具有序列数组。但是promise可以返回任何对象?
from
函数,哪个接口somePromiseFn
将返回!我建议您改为执行以下操作: