firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[FR]: Add `@discardableResult` to `CollectionReference.addDocument`

Open Eskils opened this issue 2 years ago • 2 comments

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 _ = try Firestore.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: https://github.com/Eskils/firebase-ios-sdk/commit/c44c187f92787b9978ba73e4bbbda14d6a78c665

API Proposal

No response

Firebase Product(s)

Firestore

Eskils avatar Jan 04 '23 19:01 Eskils

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jan 04 '23 19:01 google-oss-bot

If you want, you can create a PR. Otherwise, I can make the change.

Thanks!

wu-hui avatar Jan 10 '23 15:01 wu-hui