angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

AngularFirestoreCollection get function returns non generic QuerySnapshot #2438

Closed batchi92 closed 3 years ago

batchi92 commented 4 years ago

Version info

Angular: 8.2.14

Firebase: 7.14.2

AngularFire: 5.4.2

Ionic: 5.0.7

Capacitor: 2.0.1

How to reproduce these conditions

let users: Array<{ username: string }>

this.fireStore.collection<{ username: string }>('users').get().subscribe(querySnapshot => { users = querySnapshot.docs.map(doc => doc.data()) })

Debug output

Type 'DocumentData[]' is not assignable to type '{ username: string; }[]'. Property 'username' is missing in type 'DocumentData' but required in type '{ username: string; }'.

Expected behavior

The QueryDocumentSnapshot's data() functions return value should be of the type '{ username: string; }'

Actual behavior

Its return value is of the type DocumentData

jamesdaniels commented 3 years ago

Should be addressed in 6.1.0-rc.1