In my code, there was a line that looked like this:
let initialPayload = this.db.list("/members").snapshotChanges() as Observable<any[]>
But then I changed it to this:
let initialPayload = this.db.list("/members").snapshotChanges()
.pipe(map(actions => actions.map(a => ({ key: a.payload.doc.id, data: a.payload.doc.data() }) )));
Unfortunately, the second line is giving me an error message:
Property 'doc' does not exist on type DatabaseSnapshot<unknown>
I believe adding back the as Observable < any[] >
from the original code might fix this issue. However, I'm unsure of how to properly include it in the second line. Would it be like this (?):
let initialPayload = this.db.list("/members").snapshotChanges()
.pipe(map(actions => actions.map(a => ({ key: a.payload.doc.id, data: a.payload.doc.data() }) ))) as Observable<any[]>
-?
If I follow this approach and the error persists even after adding it at the end, it would mean my suspicion was incorrect. Can someone confirm if I've added it correctly?
And since you've read this far, feel free to share your thoughts on this question too: Error: Property 'doc' does not exist on type 'DatabaseSnapshot<unknown>'