Skip to content

Commit c2f7e55

Browse files
docs: add @throws API comment for CRUD methods (#1647)
1 parent 356323d commit c2f7e55

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

dev/src/bulk-writer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ export class BulkWriter {
554554
* @param {DocumentReference} documentRef A reference to the document to be
555555
* created.
556556
* @param {T} data The object to serialize as the document.
557+
* @throws {Error} If the provided input is not a valid Firestore document.
557558
* @returns {Promise<WriteResult>} A promise that resolves with the result of
558559
* the write. If the write fails, the promise is rejected with a
559560
* [BulkWriterError]{@link BulkWriterError}.
@@ -643,6 +644,7 @@ export class BulkWriter {
643644
* set.
644645
* @param {T} data The object to serialize as the document.
645646
* @param {SetOptions=} options An object to configure the set behavior.
647+
* @throws {Error} If the provided input is not a valid Firestore document.
646648
* @param {boolean=} options.merge - If true, set() merges the values
647649
* specified in its data argument. Fields omitted from this set() call remain
648650
* untouched.
@@ -711,6 +713,7 @@ export class BulkWriter {
711713
* @param {...(Precondition|*|string|FieldPath)} preconditionOrValues - An
712714
* alternating list of field paths and values to update or a Precondition to
713715
* restrict this update
716+
* @throws {Error} If the provided input is not valid Firestore data.
714717
* @returns {Promise<WriteResult>} A promise that resolves with the result of
715718
* the write. If the write fails, the promise is rejected with a
716719
* [BulkWriterError]{@link BulkWriterError}.

dev/src/reference.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ export class DocumentReference<T = firestore.DocumentData>
359359
*
360360
* @param {DocumentData} data An object that contains the fields and data to
361361
* serialize as the document.
362+
* @throws {Error} If the provided input is not a valid Firestore document.
362363
* @returns {Promise.<WriteResult>} A Promise that resolves with the
363364
* write time of this create.
364365
*
@@ -432,6 +433,7 @@ export class DocumentReference<T = firestore.DocumentData>
432433
* @param {Array.<string|FieldPath>=} options.mergeFields If provided,
433434
* set() only replaces the specified field paths. Any field path that is not
434435
* specified is ignored and remains untouched.
436+
* @throws {Error} If the provided input is not a valid Firestore document.
435437
* @returns {Promise.<WriteResult>} A Promise that resolves with the
436438
* write time of this set.
437439
*
@@ -476,6 +478,7 @@ export class DocumentReference<T = firestore.DocumentData>
476478
* ...(*|string|FieldPath|Precondition)} preconditionOrValues An alternating
477479
* list of field paths and values to update or a Precondition to restrict
478480
* this update.
481+
* @throws {Error} If the provided input is not valid Firestore data.
479482
* @returns {Promise.<WriteResult>} A Promise that resolves once the
480483
* data has been successfully written to the backend.
481484
*
@@ -2685,6 +2688,7 @@ export class CollectionReference<T = firestore.DocumentData>
26852688
*
26862689
* @param {DocumentData} data An Object containing the data for the new
26872690
* document.
2691+
* @throws {Error} If the provided input is not a valid Firestore document.
26882692
* @returns {Promise.<DocumentReference>} A Promise resolved with a
26892693
* [DocumentReference]{@link DocumentReference} pointing to the
26902694
* newly created document.

dev/src/transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class Transaction implements firestore.Transaction {
252252
* @param {Array.<string|FieldPath>=} options.mergeFields - If provided,
253253
* set() only replaces the specified field paths. Any field path that is not
254254
* specified is ignored and remains untouched.
255+
* @throws {Error} If the provided input is not a valid Firestore document.
255256
* @returns {Transaction} This Transaction instance. Used for
256257
* chaining method calls.
257258
*
@@ -300,6 +301,7 @@ export class Transaction implements firestore.Transaction {
300301
* ...(Precondition|*|string|FieldPath)} preconditionOrValues -
301302
* An alternating list of field paths and values to update or a Precondition
302303
* to to enforce on this update.
304+
* @throws {Error} If the provided input is not valid Firestore data.
303305
* @returns {Transaction} This Transaction instance. Used for
304306
* chaining method calls.
305307
*

dev/src/write-batch.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export class WriteBatch implements firestore.WriteBatch {
174174
* @param {DocumentReference} documentRef A reference to the document to be
175175
* created.
176176
* @param {T} data The object to serialize as the document.
177+
* @throws {Error} If the provided input is not a valid Firestore document.
177178
* @returns {WriteBatch} This WriteBatch instance. Used for chaining
178179
* method calls.
179180
*
@@ -302,6 +303,7 @@ export class WriteBatch implements firestore.WriteBatch {
302303
* @param {Array.<string|FieldPath>=} options.mergeFields - If provided,
303304
* set() only replaces the specified field paths. Any field path that is not
304305
* specified is ignored and remains untouched.
306+
* @throws {Error} If the provided input is not a valid Firestore document.
305307
* @returns {WriteBatch} This WriteBatch instance. Used for chaining
306308
* method calls.
307309
*
@@ -401,6 +403,7 @@ export class WriteBatch implements firestore.WriteBatch {
401403
* ...(Precondition|*|string|FieldPath)} preconditionOrValues -
402404
* An alternating list of field paths and values to update or a Precondition
403405
* to restrict this update.
406+
* @throws {Error} If the provided input is not valid Firestore data.
404407
* @returns {WriteBatch} This WriteBatch instance. Used for chaining
405408
* method calls.
406409
*

types/firestore.d.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ declare namespace FirebaseFirestore {
598598
*
599599
* @param documentRef A reference to the document to be create.
600600
* @param data The object data to serialize as the document.
601+
* @throws Error If the provided input is not a valid Firestore document.
601602
* @return This `Transaction` instance. Used for chaining method calls.
602603
*/
603604
create<T>(
@@ -613,6 +614,7 @@ declare namespace FirebaseFirestore {
613614
* @param documentRef A reference to the document to be set.
614615
* @param data An object of the fields and values for the document.
615616
* @param options An object to configure the set behavior.
617+
* @throws Error If the provided input is not a valid Firestore document.
616618
* @return This `Transaction` instance. Used for chaining method calls.
617619
*/
618620
set<T>(
@@ -637,6 +639,7 @@ declare namespace FirebaseFirestore {
637639
* @param data An object containing the fields and values with which to
638640
* update the document.
639641
* @param precondition A Precondition to enforce on this update.
642+
* @throws Error If the provided input is not valid Firestore data.
640643
* @return This `Transaction` instance. Used for chaining method calls.
641644
*/
642645
update<T>(
@@ -662,6 +665,7 @@ declare namespace FirebaseFirestore {
662665
* @param fieldsOrPrecondition An alternating list of field paths and values
663666
* to update, optionally followed by a `Precondition` to enforce on this
664667
* update.
668+
* @throws Error If the provided input is not valid Firestore data.
665669
* @return This `Transaction` instance. Used for chaining method calls.
666670
*/
667671
update(
@@ -700,6 +704,7 @@ declare namespace FirebaseFirestore {
700704
* @param documentRef A reference to the document to be
701705
* created.
702706
* @param data The object to serialize as the document.
707+
* @throws Error If the provided input is not a valid Firestore document.
703708
* @returns A promise that resolves with the result of the write. If the
704709
* write fails, the promise is rejected with a
705710
* [BulkWriterError]{@link BulkWriterError}.
@@ -747,6 +752,7 @@ declare namespace FirebaseFirestore {
747752
* @param options.mergeFields - If provided,
748753
* set() only replaces the specified field paths. Any field path that is not
749754
* specified is ignored and remains untouched.
755+
* @throws Error If the provided input is not a valid Firestore document.
750756
* @returns A promise that resolves with the result of the write. If the
751757
* write fails, the promise is rejected with a
752758
* [BulkWriterError]{@link BulkWriterError}.
@@ -780,6 +786,7 @@ declare namespace FirebaseFirestore {
780786
* @param data An object containing the fields and values with which to
781787
* update the document.
782788
* @param precondition A Precondition to enforce on this update.
789+
* @throws Error If the provided input is not valid Firestore data.
783790
* @returns A promise that resolves with the result of the write. If the
784791
* write fails, the promise is rejected with a
785792
* [BulkWriterError]{@link BulkWriterError}.
@@ -809,7 +816,9 @@ declare namespace FirebaseFirestore {
809816
* @param field The first field to update.
810817
* @param value The first value
811818
* @param fieldsOrPrecondition An alternating list of field paths and values
812-
* to update, optionally followed a `Precondition` to enforce on this update.
819+
* to update, optionally followed a `Precondition` to enforce on this
820+
* update.
821+
* @throws Error If the provided input is not valid Firestore data;
813822
* @returns A promise that resolves with the result of the write. If the
814823
* write fails, the promise is rejected with a
815824
* [BulkWriterError]{@link BulkWriterError}.
@@ -953,6 +962,7 @@ declare namespace FirebaseFirestore {
953962
*
954963
* @param documentRef A reference to the document to be created.
955964
* @param data The object data to serialize as the document.
965+
* @throws Error If the provided input is not a valid Firestore document.
956966
* @return This `WriteBatch` instance. Used for chaining method calls.
957967
*/
958968
create<T>(
@@ -968,6 +978,7 @@ declare namespace FirebaseFirestore {
968978
* @param documentRef A reference to the document to be set.
969979
* @param data An object of the fields and values for the document.
970980
* @param options An object to configure the set behavior.
981+
* @throws Error If the provided input is not a valid Firestore document.
971982
* @return This `WriteBatch` instance. Used for chaining method calls.
972983
*/
973984
set<T>(
@@ -992,6 +1003,7 @@ declare namespace FirebaseFirestore {
9921003
* @param data An object containing the fields and values with which to
9931004
* update the document.
9941005
* @param precondition A Precondition to enforce on this update.
1006+
* @throws Error If the provided input is not valid Firestore data.
9951007
* @return This `WriteBatch` instance. Used for chaining method calls.
9961008
*/
9971009
update<T>(
@@ -1015,7 +1027,9 @@ declare namespace FirebaseFirestore {
10151027
* @param field The first field to update.
10161028
* @param value The first value
10171029
* @param fieldsOrPrecondition An alternating list of field paths and values
1018-
* to update, optionally followed a `Precondition` to enforce on this update.
1030+
* to update, optionally followed a `Precondition` to enforce on this
1031+
* update.
1032+
* @throws Error If the provided input is not valid Firestore data.
10191033
* @return This `WriteBatch` instance. Used for chaining method calls.
10201034
*/
10211035
update(
@@ -1174,6 +1188,7 @@ declare namespace FirebaseFirestore {
11741188
* provided object values. The write fails if the document already exists
11751189
*
11761190
* @param data The object data to serialize as the document.
1191+
* @throws Error If the provided input is not a valid Firestore document.
11771192
* @return A Promise resolved with the write time of this create.
11781193
*/
11791194
create(data: WithFieldValue<T>): Promise<WriteResult>;
@@ -1185,6 +1200,7 @@ declare namespace FirebaseFirestore {
11851200
*
11861201
* @param data A map of the fields and values for the document.
11871202
* @param options An object to configure the set behavior.
1203+
* @throws Error If the provided input is not a valid Firestore document.
11881204
* @return A Promise resolved with the write time of this set.
11891205
*/
11901206
set(
@@ -1203,6 +1219,7 @@ declare namespace FirebaseFirestore {
12031219
* @param data An object containing the fields and values with which to
12041220
* update the document.
12051221
* @param precondition A Precondition to enforce on this update.
1222+
* @throws Error If the provided input is not valid Firestore data.
12061223
* @return A Promise resolved with the write time of this update.
12071224
*/
12081225
update(
@@ -1225,6 +1242,7 @@ declare namespace FirebaseFirestore {
12251242
* @param moreFieldsOrPrecondition An alternating list of field paths and
12261243
* values to update, optionally followed by a `Precondition` to enforce on
12271244
* this update.
1245+
* @throws Error If the provided input is not valid Firestore data.
12281246
* @return A Promise resolved with the write time of this update.
12291247
*/
12301248
update(
@@ -1816,6 +1834,7 @@ declare namespace FirebaseFirestore {
18161834
* it a document ID automatically.
18171835
*
18181836
* @param data An Object containing the data for the new document.
1837+
* @throws Error If the provided input is not a valid Firestore document.
18191838
* @return A Promise resolved with a `DocumentReference` pointing to the
18201839
* newly created document after it has been written to the backend.
18211840
*/

0 commit comments

Comments
 (0)