-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
The return type of the AngularFirestoreDocument.get() is not set, this will cause the editor cant perform autocomplete when calling DocumentSnapshot.data() because it will just treat its return type, as firestore.DocumentData instead the real type.
Version info
Angular: 9.0.7
Firebase: 7.11.0
AngularFire: 5.4.2
Other (e.g. Ionic/Cordova, Node, browser, operating system):
Node: v12.6
npm: 6.14.2
Browser: Latest chrome and firefox nightly.
How to reproduce these conditions
export class Sample {
constructor(private afStore AngularFirestore) {}
test(path: string) {
this.afStore.doc<SampleType>(path).get().pipe(take(1)).subscribe(doc => {
console.log(doc.data()); // The real type of doc.data() is not infered by the editor.
})
}
}Expected behavior
The return type should be
Observable<firebase.firestore.DocumentSnapshot<firebase.firestore.SamlpeType>>This will allow to infer the type of the doc.data()
Actual behavior
The return type is
Observable<firebase.firestore.DocumentSnapshot<firebase.firestore.DocumentData>>With this the autocomplete will not work
Possible Solution
Based on index.d.ts on firestore, it is implemented like this.
export class DocumentSnapshot<T = DocumentData> {
data(options?: SnapshotOptions): T | undefined;
}I think setting the return type of get on document.ts to
get(options?: firestore.GetOptions): Observable<firestore.DocumentSnapshot<T>>will fix the issue.
Khalid-Nowaf, KingDarBoja and davidecampelloGuateDevIO
Metadata
Metadata
Assignees
Labels
No labels

