Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Im getting an error "Spread types may only be created from object types.ts(2698)"
import { Injectable } from '@angular/core';
import { AngularFirestore } from '@angular/fire/firestore';
import { map } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class FirestoreDbService {

  constructor(private db: AngularFirestore) { }

  getBuildList() {
    // return this.db.collection('Builds').valueChanges();
    return this.db.collection('Builds').snapshotChanges().pipe(
      map(docArray => {
        return docArray.map(doc => {
          console.log('==', doc.payload.doc.id);
          console.log('$==$', doc.payload.doc.data());
          return{
            id: doc.payload.doc.id,
            ... doc.payload.doc.data()
          }
        })
      })
    )
  }
}

On the last line I am getting the error. I think this is something to do with typescript. Any help appreciated

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use the as keyword:

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

This will tell the compiler to treat doc.payload.doc.data() as an object.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!