@@ -83,23 +83,30 @@ import { SnapshotListenOptions } from './reference_impl';
83
83
* }
84
84
* ```
85
85
*/
86
- export interface FirestoreDataConverter < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > extends LiteFirestoreDataConverter < AppType , DbType > {
86
+ export interface FirestoreDataConverter <
87
+ AppType = DocumentData ,
88
+ DbType extends DocumentData = AppType extends DocumentData
89
+ ? AppType
90
+ : DocumentData
91
+ > extends LiteFirestoreDataConverter < AppType , DbType > {
87
92
/**
88
- * Called by the Firestore SDK to convert a custom model object of type `T`
89
- * into a plain JavaScript object (suitable for writing directly to the
90
- * Firestore database). To use `set()` with `merge` and `mergeFields`,
91
- * `toFirestore()` must be defined with `PartialWithFieldValue<T>`.
93
+ * Called by the Firestore SDK to convert a custom model object of type
94
+ * `AppType` into a plain JavaScript object, `DbType` (suitable for writing
95
+ * directly to the Firestore database). To use `set()` with `merge` and
96
+ * mergeFields`, `toFirestore()` must be defined with
97
+ * `PartialWithFieldValue<T>`.
92
98
*
93
99
* The `WithFieldValue<T>` type extends `T` to also allow FieldValues such as
94
100
* {@link (deleteField:1)} to be used as property values.
95
101
*/
96
102
toFirestore ( modelObject : WithFieldValue < AppType > ) : WithFieldValue < DbType > ;
97
103
98
104
/**
99
- * Called by the Firestore SDK to convert a custom model object of type `T`
100
- * into a plain JavaScript object (suitable for writing directly to the
101
- * Firestore database). Used with {@link (setDoc:1)}, {@link (WriteBatch.set:1)}
102
- * and {@link (Transaction.set:1)} with `merge:true` or `mergeFields`.
105
+ * Called by the Firestore SDK to convert a custom model object of type
106
+ * `AppType` into a plain JavaScript object, `DbType` (suitable for writing
107
+ * directly to the Firestore database). Used with {@link (setDoc:1)},
108
+ * {@link (WriteBatch.set:1)} and {@link (Transaction.set:1)} with
109
+ * `merge:true` or `mergeFields`.
103
110
*
104
111
* The `PartialWithFieldValue<T>` type extends `Partial<T>` to allow
105
112
* FieldValues such as {@link (arrayUnion:1)} to be used as property values.
@@ -113,7 +120,8 @@ export interface FirestoreDataConverter<AppType = DocumentData, DbType extends D
113
120
114
121
/**
115
122
* Called by the Firestore SDK to convert Firestore data into an object of
116
- * type T. You can access your data by calling: `snapshot.data(options)`.
123
+ * type `AppType`. You can access your data by calling:
124
+ * `snapshot.data(options)`.
117
125
*
118
126
* @param snapshot - A `QueryDocumentSnapshot` containing your data and metadata.
119
127
* @param options - The `SnapshotOptions` from the initial call to `data()`.
@@ -199,7 +207,12 @@ export type DocumentChangeType = 'added' | 'removed' | 'modified';
199
207
* A `DocumentChange` represents a change to the documents matching a query.
200
208
* It contains the document affected and the type of change that occurred.
201
209
*/
202
- export interface DocumentChange < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
210
+ export interface DocumentChange <
211
+ AppType = DocumentData ,
212
+ DbType extends DocumentData = AppType extends DocumentData
213
+ ? AppType
214
+ : DocumentData
215
+ > {
203
216
/** The type of change ('added', 'modified', or 'removed'). */
204
217
readonly type : DocumentChangeType ;
205
218
@@ -231,7 +244,12 @@ export interface DocumentChange<AppType = DocumentData, DbType extends DocumentD
231
244
* access will return 'undefined'. You can use the `exists()` method to
232
245
* explicitly verify a document's existence.
233
246
*/
234
- export class DocumentSnapshot < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > extends LiteDocumentSnapshot < AppType , DbType > {
247
+ export class DocumentSnapshot <
248
+ AppType = DocumentData ,
249
+ DbType extends DocumentData = AppType extends DocumentData
250
+ ? AppType
251
+ : DocumentData
252
+ > extends LiteDocumentSnapshot < AppType , DbType > {
235
253
private readonly _firestoreImpl : Firestore ;
236
254
237
255
/**
@@ -343,7 +361,12 @@ export class DocumentSnapshot<AppType = DocumentData, DbType extends DocumentDat
343
361
* `exists` property will always be true and `data()` will never return
344
362
* 'undefined'.
345
363
*/
346
- export class QueryDocumentSnapshot < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > extends DocumentSnapshot < AppType , DbType > {
364
+ export class QueryDocumentSnapshot <
365
+ AppType = DocumentData ,
366
+ DbType extends DocumentData = AppType extends DocumentData
367
+ ? AppType
368
+ : DocumentData
369
+ > extends DocumentSnapshot < AppType , DbType > {
347
370
/**
348
371
* Retrieves all fields in the document as an `Object`.
349
372
*
@@ -369,7 +392,12 @@ export class QueryDocumentSnapshot<AppType = DocumentData, DbType extends Docume
369
392
* number of documents can be determined via the `empty` and `size`
370
393
* properties.
371
394
*/
372
- export class QuerySnapshot < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
395
+ export class QuerySnapshot <
396
+ AppType = DocumentData ,
397
+ DbType extends DocumentData = AppType extends DocumentData
398
+ ? AppType
399
+ : DocumentData
400
+ > {
373
401
/**
374
402
* Metadata about this snapshot, concerning its source and if it has local
375
403
* modifications.
@@ -454,7 +482,9 @@ export class QuerySnapshot<AppType = DocumentData, DbType extends DocumentData =
454
482
* changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger
455
483
* snapshot events.
456
484
*/
457
- docChanges ( options : SnapshotListenOptions = { } ) : Array < DocumentChange < AppType , DbType > > {
485
+ docChanges (
486
+ options : SnapshotListenOptions = { }
487
+ ) : Array < DocumentChange < AppType , DbType > > {
458
488
const includeMetadataChanges = ! ! options . includeMetadataChanges ;
459
489
460
490
if ( includeMetadataChanges && this . _snapshot . excludesMetadataChanges ) {
@@ -583,7 +613,15 @@ export function resultChangeType(type: ChangeType): DocumentChangeType {
583
613
* @param right - A snapshot to compare.
584
614
* @returns true if the snapshots are equal.
585
615
*/
586
- export function snapshotEqual < AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > ( left : DocumentSnapshot < AppType , DbType > | QuerySnapshot < AppType , DbType > , right : DocumentSnapshot < AppType , DbType > | QuerySnapshot < AppType , DbType > ) : boolean {
616
+ export function snapshotEqual <
617
+ AppType = DocumentData ,
618
+ DbType extends DocumentData = AppType extends DocumentData
619
+ ? AppType
620
+ : DocumentData
621
+ > (
622
+ left : DocumentSnapshot < AppType , DbType > | QuerySnapshot < AppType , DbType > ,
623
+ right : DocumentSnapshot < AppType , DbType > | QuerySnapshot < AppType , DbType >
624
+ ) : boolean {
587
625
if ( left instanceof DocumentSnapshot && right instanceof DocumentSnapshot ) {
588
626
return (
589
627
left . _firestore === right . _firestore &&
0 commit comments