AngularFire 7 Document Typing
See original GitHub issueHave we lost document typing with the upgrade to AngularFire 7?
In the past, we were able to do (as shown in the docs) something like afs.doc<Item>('items/1')
and that would return DocumentReference<Item>
as the type.
Now it looks like the functions that exist are
function doc(firestore: types.FirebaseFirestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
function doc<T>(reference: types.CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
function doc(reference: types.DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
The only one that is typed is the one that takes in a previous collection reference. Meanwhile, this first is the one we’re directed to use in the upgrade documentation and it only uses DocumentData. One of the big benefits to using AngularFire previously over the vanilla Firebase libraries was the fact that DocumentData didn’t have to be cast. Has that now been removed?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to get a typed object with angularfire 7+ (firebase 9)
The easiest solution is just to cast your document reference like this: const docReference = doc( this.firestore, 'queues/' + userId ) as ...
Read more >Developers - AngularFire 7 Document Typing - - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >Creating CRUD Firebase documents in Angular
This extensive tutorial shows you how to Create, Read, Update, and Delete (CRUD) Firebase documents in Angular.
Read more >Angular 13 Firebase Authentication Tutorial With AngularFire 7
ts file. Adding routes the app-routing module. Note that we're adding a wildcard route, that ...
Read more >Angular 7 CRUD using Firestore - YouTube
Angular 7 CRUD operations implemented using FirestoreIn this lesson, ... After selecting a record user can update a Firestore document.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jamesdaniels does this mean we will eventually get functionality in line with the current documentation, or that the documentation will be updated to reflect the new (seemingly downgraded) doc and collection type setting?
It seems Firestore isn’t allowing one to override the typings, only allowing types to be inferred if using a converter. Converters are “better” in the sense that you can have real run-time checks to guard you against data that doesn’t conform to your expectations but they can be overly verbose.
I’ll address in a future release of Angular/RxFire.