@@ -127,6 +127,7 @@ import {
127127 NextFn ,
128128 PartialObserver
129129} from './observer' ;
130+ import { NestedPartialWithFieldValue , WithFieldValue } from '../lite/reference' ;
130131
131132/**
132133 * A persistence provider for either memory-only or IndexedDB persistence.
@@ -597,19 +598,19 @@ class FirestoreDataConverter<U>
597598 ) ;
598599 }
599600
600- toFirestore ( modelObject : U ) : PublicDocumentData ;
601+ toFirestore ( modelObject : WithFieldValue < U > ) : PublicDocumentData ;
601602 toFirestore (
602- modelObject : Partial < U > ,
603+ modelObject : NestedPartialWithFieldValue < U > ,
603604 options : PublicSetOptions
604605 ) : PublicDocumentData ;
605606 toFirestore (
606- modelObject : U | Partial < U > ,
607+ modelObject : WithFieldValue < U > | NestedPartialWithFieldValue < U > ,
607608 options ?: PublicSetOptions
608609 ) : PublicDocumentData {
609610 if ( ! options ) {
610611 return this . _delegate . toFirestore ( modelObject as U ) ;
611612 } else {
612- return this . _delegate . toFirestore ( modelObject , options ) ;
613+ return this . _delegate . toFirestore ( modelObject as Partial < U > , options ) ;
613614 }
614615 }
615616
@@ -733,7 +734,15 @@ export class DocumentReference<T = PublicDocumentData>
733734 set ( value : T | Partial < T > , options ?: PublicSetOptions ) : Promise < void > {
734735 options = validateSetOptions ( 'DocumentReference.set' , options ) ;
735736 try {
736- return setDoc ( this . _delegate , value , options ) ;
737+ if ( options ) {
738+ return setDoc (
739+ this . _delegate ,
740+ value as NestedPartialWithFieldValue < T > ,
741+ options
742+ ) ;
743+ } else {
744+ return setDoc ( this . _delegate , value as WithFieldValue < T > ) ;
745+ }
737746 } catch ( e ) {
738747 throw replaceFunctionName ( e , 'setDoc()' , 'DocumentReference.set()' ) ;
739748 }
0 commit comments