Skip to content

AngularFire 7 Document Typing #2931

Open
@kevin-induro

Description

@kevin-induro

Have 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions