@@ -50,9 +50,9 @@ export type LogLevel =
50
50
export function setLogLevel ( logLevel : LogLevel ) : void ;
51
51
52
52
export interface FirestoreDataConverter <
53
- AppModelType ,
54
- DbModelType extends DocumentData = DocumentData
55
- > {
53
+ AppModelType ,
54
+ DbModelType extends DocumentData = DocumentData
55
+ > {
56
56
toFirestore ( modelObject : AppModelType ) : DocumentData ;
57
57
toFirestore ( modelObject : Partial < AppModelType > , options : SetOptions ) : DocumentData ;
58
58
@@ -188,45 +188,53 @@ export class Blob {
188
188
export class Transaction {
189
189
private constructor ( ) ;
190
190
191
- get < T > ( documentRef : DocumentReference < AppModelType , DbModelType > ) : Promise < DocumentSnapshot < AppModelType , DbModelType > > ;
191
+ get < AppModelType , DbModelType extends DocumentData > (
192
+ documentRef : DocumentReference < AppModelType , DbModelType >
193
+ ) : Promise < DocumentSnapshot < AppModelType , DbModelType > > ;
192
194
193
- set < T > (
195
+ set < AppModelType , DbModelType extends DocumentData > (
194
196
documentRef : DocumentReference < AppModelType , DbModelType > ,
195
- data : Partial < T > ,
197
+ data : Partial < AppModelType > ,
196
198
options : SetOptions
197
199
) : Transaction ;
198
- set < T > ( documentRef : DocumentReference < AppModelType , DbModelType > , data : T ) : Transaction ;
200
+ set < AppModelType , DbModelType extends DocumentData > (
201
+ documentRef : DocumentReference < AppModelType , DbModelType > ,
202
+ data : Partial < AppModelType >
203
+ ) : Transaction ;
199
204
200
- update ( documentRef : DocumentReference < any > , data : UpdateData ) : Transaction ;
201
- update (
202
- documentRef : DocumentReference < any > ,
205
+ update < AppModelType , DbModelType extends DocumentData > (
206
+ documentRef : DocumentReference < AppModelType , DbModelType > ,
207
+ data : Partial < AppModelType >
208
+ ) : Transaction ;
209
+ update < AppModelType , DbModelType extends DocumentData > (
210
+ documentRef : DocumentReference < AppModelType , DbModelType > ,
203
211
field : string | FieldPath ,
204
212
value : any ,
205
213
...moreFieldsAndValues : any [ ]
206
214
) : Transaction ;
207
215
208
- delete ( documentRef : DocumentReference < any > ) : Transaction ;
216
+ delete < AppModelType , DbModelType extends DocumentData > ( documentRef : DocumentReference < AppModelType , DbModelType > ) : Transaction ;
209
217
}
210
218
211
219
export class WriteBatch {
212
220
private constructor ( ) ;
213
221
214
- set < T > (
222
+ set < AppModelType , DbModelType extends DocumentData > (
215
223
documentRef : DocumentReference < AppModelType , DbModelType > ,
216
- data : Partial < T > ,
224
+ data : Partial < AppModelType > ,
217
225
options : SetOptions
218
226
) : WriteBatch ;
219
- set < T > ( documentRef : DocumentReference < AppModelType , DbModelType > , data : T ) : WriteBatch ;
227
+ set < AppModelType , DbModelType extends DocumentData > ( documentRef : DocumentReference < AppModelType , DbModelType > , data : UpdateData ) : WriteBatch ;
220
228
221
- update ( documentRef : DocumentReference < any > , data : UpdateData ) : WriteBatch ;
222
- update (
223
- documentRef : DocumentReference < any > ,
229
+ update < AppModelType , DbModelType extends DocumentData > ( documentRef : DocumentReference < AppModelType , DbModelType > , data : UpdateData ) : WriteBatch ;
230
+ update < AppModelType , DbModelType extends DocumentData > (
231
+ documentRef : DocumentReference < AppModelType , DbModelType > ,
224
232
field : string | FieldPath ,
225
233
value : any ,
226
234
...moreFieldsAndValues : any [ ]
227
235
) : WriteBatch ;
228
236
229
- delete ( documentRef : DocumentReference < any > ) : WriteBatch ;
237
+ delete < AppModelType , DbModelType extends DocumentData > ( documentRef : DocumentReference < AppModelType , DbModelType > ) : WriteBatch ;
230
238
231
239
commit ( ) : Promise < void > ;
232
240
}
@@ -256,8 +264,8 @@ export class DocumentReference<AppModelType, DbModelType> {
256
264
257
265
isEqual ( other : DocumentReference < AppModelType , DbModelType > ) : boolean ;
258
266
259
- set ( data : Partial < T > , options : SetOptions ) : Promise < void > ;
260
- set ( data : T ) : Promise < void > ;
267
+ set ( data : Partial < AppModelType > , options : SetOptions ) : Promise < void > ;
268
+ set ( data : Partial < AppModelType > ) : Promise < void > ;
261
269
262
270
update ( data : UpdateData ) : Promise < void > ;
263
271
update (
@@ -295,8 +303,10 @@ export class DocumentReference<AppModelType, DbModelType> {
295
303
onCompletion ?: ( ) => void
296
304
) : ( ) => void ;
297
305
298
- withConverter ( converter : null ) : DocumentReference < DocumentData > ;
299
- withConverter < U > ( converter : FirestoreDataConverter < U > ) : DocumentReference < U > ;
306
+ withConverter ( converter : null ) : DocumentReference < AppModelType , DbModelType > ;
307
+ withConverter < AppModelType , DbModelType > (
308
+ converter : FirestoreDataConverter < AppModelType , DbModelType >
309
+ ) : DocumentReference < AppModelType , DbModelType > ;
300
310
}
301
311
302
312
export interface SnapshotOptions {
@@ -318,7 +328,7 @@ export class DocumentSnapshot<AppModelType, DbModelType> {
318
328
readonly id : string ;
319
329
readonly metadata : SnapshotMetadata ;
320
330
321
- data ( options ?: SnapshotOptions ) : T | undefined ;
331
+ data ( options ?: SnapshotOptions ) : AppModelType | undefined ;
322
332
323
333
get ( fieldPath : string | FieldPath , options ?: SnapshotOptions ) : any ;
324
334
@@ -329,7 +339,7 @@ export class QueryDocumentSnapshot<AppModelType, DbModelType>
329
339
extends DocumentSnapshot < AppModelType , DbModelType > {
330
340
private constructor ( ) ;
331
341
332
- data ( options ?: SnapshotOptions ) : T ;
342
+ data ( options ?: SnapshotOptions ) : AppModelType ;
333
343
}
334
344
335
345
export type OrderByDirection = 'desc' | 'asc' ;
@@ -420,7 +430,7 @@ export class QuerySnapshot<AppModelType, DbModelType> {
420
430
readonly size : number ;
421
431
readonly empty : boolean ;
422
432
423
- docChanges ( options ?: SnapshotListenOptions ) : Array < DocumentChange < T > > ;
433
+ docChanges ( options ?: SnapshotListenOptions ) : Array < DocumentChange < AppModelType , DbModelType > > ;
424
434
425
435
forEach (
426
436
callback : ( result : QueryDocumentSnapshot < AppModelType , DbModelType > ) => void ,
@@ -439,18 +449,21 @@ export interface DocumentChange<AppModelType, DbModelType> {
439
449
readonly newIndex : number ;
440
450
}
441
451
442
- export class CollectionReference < AppModelType = DocumentData , DbModelType extends DocumentData = DocumentData > extends Query < AppModelType , DbModelType > {
452
+ export class CollectionReference <
453
+ AppModelType = DocumentData ,
454
+ DbModelType extends DocumentData = DocumentData
455
+ > extends Query < AppModelType , DbModelType > {
443
456
private constructor ( ) ;
444
457
445
458
readonly id : string ;
446
- readonly parent : DocumentReference < AppModelType , DbModelType > | null ;
459
+ readonly parent : DocumentReference < AppModelType , DbModelType > | null ;
447
460
readonly path : string ;
448
461
449
462
doc ( documentPath ?: string ) : DocumentReference < AppModelType , DbModelType > ;
450
463
451
- add ( data : T ) : Promise < DocumentReference < AppModelType , DbModelType > > ;
464
+ add ( data : AppModelType ) : Promise < DocumentReference < AppModelType , DbModelType > > ;
452
465
453
- isEqual ( other : CollectionReference < T > ) : boolean ;
466
+ isEqual ( other : CollectionReference < AppModelType , DbModelType > ) : boolean ;
454
467
455
468
withConverter ( converter : null ) : CollectionReference < DocumentData > ;
456
469
withConverter < U > (
0 commit comments