RxJS 6:使用TypescriptTypings从Promise迁移至from

问题描述 投票:0回答:1

如何在保持输入正确的同时从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可以返回任何对象?

typescript rxjs rxjs6
1个回答
0
投票
这听起来有点奇怪,因为您要告诉from函数,哪个接口somePromiseFn将返回!我建议您改为执行以下操作:
© www.soinside.com 2019 - 2024. All rights reserved.