【发布时间】:2017-02-07 17:42:07
【问题描述】:
我正在尝试使用 angular-cli 生成的项目将 firebase.Promise 转换为 Observable。
Here据说firebase.Promise兼容Native Promise和Promise/A+的实现。
但是,当我尝试使用 rxjs 的 Observable.fromPromise() 方法时出现错误。
Argument of type 'firebase.Promise<any>' is not assignable to parameter of type 'Promise<any>'.
Types of property 'then' are incompatible.
Type '(onResolve?: (a: any) => any, onReject?: (a: Error) => any) => Promise<any>' is not assignable to type '{ <TResult1, TResult2>(onfulfilled: (value:
any) => TResult1 | PromiseLike<TResult1>, onrejected:...'.
Type 'firebase.Promise<any>' is not assignable to type 'Promise<any>'.
它确实有效,但是出错很烦人,有什么想法可以以一种干净的方式避免这个错误吗?
谢谢。
【问题讨论】:
-
你在使用 TypeScript 吗?
-
是的,我正在使用 TS
标签: angular typescript firebase rxjs angularfire2