简体   繁体   English

传播类型只能从对象类型创建。 问题出现在 Angular 9

[英]Spread types may only be created from object types. Problem arrives with Angular 9

getIssuersCollection() {
return this.afs
  .collection('issuers')
  .snapshotChanges()
  .pipe(
    map(docArray => {
      return docArray.map(doc => {
        return {
          id: doc.payload.doc.id,
          ...doc.payload.doc.data()
        };
      });
    })
  );

} }

The above code worked fine in Angular 8 but throw's an error in Angular 9. Is there an easy fix?上面的代码在 Angular 8 中运行良好,但在 Angular 9 中抛出错误。有没有简单的修复方法?

use Object.assign({},doc.payload.doc.data) instead of it for quick fix i think我认为使用 Object.assign({},doc.payload.doc.data) 而不是它来快速修复

or try ...doc.payload.doc.data() as {}或尝试 ...doc.payload.doc.data() as {}

Not sure this help but try to revert the order like this不确定这有帮助,但尝试恢复这样的顺序

return {
          ...doc.payload.doc.data()
          id: doc.payload.doc.id,
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM