Gsuz
Gsuz

Reputation: 353

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?

Upvotes: 1

Views: 174

Answers (2)

Tony
Tony

Reputation: 20092

Not sure this help but try to revert the order like this

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

Upvotes: 0

Amey
Amey

Reputation: 815

use Object.assign({},doc.payload.doc.data) instead of it for quick fix i think

or try ...doc.payload.doc.data() as {}

Upvotes: 2

Related Questions