Firestore集合:复合查询因AngularFire2 v5.rc6而失败

时间:2018-02-15 10:02:11

标签: firebase google-cloud-firestore angularfire2

我在与AngularFire2文档上显示的集合查询非常相似的查询中收到此错误:

this.shops$ = this.afs.collection<IShop>('shops', ref => {
  let query: firebase.firestore.CollectionReference | firebase.firestore.Query = ref;

错误(在ref =>上):

Argument of type '(ref: CollectionReference) => CollectionReference | Query' is not assignable to parameter of type 'QueryFn'.
  Type 'CollectionReference | Query' is not assignable to type 'Query'.
    Type 'CollectionReference' is not assignable to type 'Query'.
      Types of property 'firestore' are incompatible.
        Type 'Firestore' is not assignable to type 'FirebaseFirestore'.
          Property 'enableNetwork' is missing in type 'Firestore'.

这种情况发生在AngularFire2上:5.0.0-rc.6和firebase:4.9.1并且不会发生在AngularFire2上:5.0.0-rc.4和firebase:4.9.1设置。

是否有更改我不知道我必须为最新版本的应用设置做什么?

1 个答案:

答案 0 :(得分:0)

刚刚通过github找到答案(所有信用都转到jeremyben

使用随最近的firebase更新添加的类型:

从&#39; @ firebase / firestore-types&#39;

导入{查询}

然后将您的引用转换为查询:

让查询:Query = ref;