Skip to content

[FR]: Add @discardableResult to CollectionReference.addDocument #10640

@Eskils

Description

@Eskils

Description

Currently, when adding an Encodable document to a collection, the addDocument method returns a DocumentReference. Often this is not need and thus generates a warning in Xcode which can be silenced by

let _ =tryFirestore.firestore().collection("collectionName").addDocument(from: encodable)

To improve developer experience I suggest to add the @discardableResult attribute to the addDocument method which will tell the Swift compiler that it is okay for the return value to be unused.

See required changes here: Eskils@c44c187

API Proposal

No response

Firebase Product(s)

Firestore

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close