@@ -101,7 +101,7 @@ toFirestore(modelObject: PartialWithFieldValue<AppModelType>, options: SetOption
101101Simple Example
102102
103103` ` ` typescript
104- const numberConverter: FirestoreDataConverter<number, {value: number}> = {
104+ const numberConverter = {
105105 toFirestore(value: WithFieldValue<number>) {
106106 return { value };
107107 },
@@ -152,19 +152,19 @@ interface PostDbModel {
152152 lut: Timestamp;
153153}
154154
155- // The ` PostConverter ` implements ` FirestoreDataConverter < AppModelType , DbModelType > `
156- // and specifies how the Firestore SDK can convert ` Post ` objects to ` PostDbModel `
155+ // The ` PostConverter ` implements ` FirestoreDataConverter ` and specifies
156+ // how the Firestore SDK can convert ` Post ` objects to ` PostDbModel `
157157// objects and vice versa.
158158class PostConverter implements FirestoreDataConverter<Post, PostDbModel> {
159- toFirestore(post: WithFieldValue<Post>) {
159+ toFirestore(post: WithFieldValue<Post>): WithFieldValue<PostDbModel> {
160160 return {
161161 ttl: post.title,
162162 aut: this._autFromAuthor(post.author),
163163 lut: this._lutFromLastUpdatedMillis(post.lastUpdatedMillis)
164164 };
165165 }
166166
167- fromFirestore(snapshot: QueryDocumentSnapshot, options: SnapshotOptions) {
167+ fromFirestore(snapshot: QueryDocumentSnapshot, options: SnapshotOptions): Post {
168168 const data = snapshot.data(options) as PostDbModel;
169169 const author = ` $ {data .aut .firstName } $ {data .aut .lastName }` ;
170170 return new Post(data.ttl, author, data.lut.toMillis());
@@ -209,7 +209,7 @@ async function advancedDemo(db: Firestore): Promise<void> {
209209 });
210210
211211 // The TypeScript compiler will fail to compile if the ` data ` argument to
212- // ` setDoc ()` is _not_ be compatible with ` WithFieldValue <Post >` . This
212+ // ` setDoc ()` is _not_ compatible with ` WithFieldValue <Post >` . This
213213 // type checking prevents the caller from specifying objects with incorrect
214214 // properties or property values.
215215 // @ts-expect-error "Argument of type { ttl: string; } is not assignable
@@ -234,15 +234,15 @@ async function advancedDemo(db: Firestore): Promise<void> {
234234 // ` PostDbModel ` . Similar to ` setDoc ()` , since the ` data ` argument is typed
235235 // as ` WithFieldValue <PostDbModel >` rather than just ` PostDbModel ` , this
236236 // allows properties of the ` data ` argument to also be those special
237- // Firestore values, like as ` arrayRemove ()` , ` deleteField ()` , and
237+ // Firestore values, like ` arrayRemove ()` , ` deleteField ()` , and
238238 // ` serverTimestamp ()` .
239239 await updateDoc(documentRef, {
240240 'aut.firstName': 'NewFirstName',
241241 lut: serverTimestamp()
242242 });
243243
244244 // The TypeScript compiler will fail to compile if the ` data ` argument to
245- // ` updateDoc ()` is _not_ be compatible with ` WithFieldValue <PostDbModel >` .
245+ // ` updateDoc ()` is _not_ compatible with ` WithFieldValue <PostDbModel >` .
246246 // This type checking prevents the caller from specifying objects with
247247 // incorrect properties or property values.
248248 // @ts-expect-error "Argument of type { title: string; } is not assignable
0 commit comments