Skip to content

Commit 3df2e8e

Browse files
committed
Format code
1 parent 5f13c37 commit 3df2e8e

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

packages/firestore/src/api/database.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,9 @@ export class WriteBatch
558558
* experimental SDK into corresponding types from the Classic SDK before passing
559559
* them to the wrapped converter.
560560
*/
561-
class FirestoreDataConverter<U> extends Compat<PublicFirestoreDataConverter<U>> implements UntypedFirestoreDataConverter<U> {
562-
561+
class FirestoreDataConverter<U>
562+
extends Compat<PublicFirestoreDataConverter<U>>
563+
implements UntypedFirestoreDataConverter<U> {
563564
private static readonly INSTANCES = new WeakMap();
564565

565566
private constructor(
@@ -570,8 +571,24 @@ class FirestoreDataConverter<U> extends Compat<PublicFirestoreDataConverter<U>>
570571
super(delegate);
571572
}
572573

573-
fromFirestore(snapshot: ExpQueryDocumentSnapshot, options?: PublicSnapshotOptions): U {
574-
return this._delegate.fromFirestore(new QueryDocumentSnapshot<U>(this._firestore, new ExpQueryDocumentSnapshot<U>(this._firestore._delegate, this._userDataWriter, snapshot._key, snapshot._document, snapshot.metadata,/* converter= */ null)), options ?? {});
574+
fromFirestore(
575+
snapshot: ExpQueryDocumentSnapshot,
576+
options?: PublicSnapshotOptions
577+
): U {
578+
return this._delegate.fromFirestore(
579+
new QueryDocumentSnapshot<U>(
580+
this._firestore,
581+
new ExpQueryDocumentSnapshot<U>(
582+
this._firestore._delegate,
583+
this._userDataWriter,
584+
snapshot._key,
585+
snapshot._document,
586+
snapshot.metadata,
587+
/* converter= */ null
588+
)
589+
),
590+
options ?? {}
591+
);
575592
}
576593

577594
toFirestore(modelObject: U): PublicDocumentData;
@@ -593,7 +610,10 @@ class FirestoreDataConverter<U> extends Compat<PublicFirestoreDataConverter<U>>
593610
// Use the same instance of `FirestoreDataConverter` for the given instances
594611
// of `Firestore` and `PublicFirestoreDataConverter` so that isEqual() will
595612
// compare equal for two objects created with the same converter instance.
596-
static getInstance<U>(firestore: Firestore, converter: PublicFirestoreDataConverter<U>): FirestoreDataConverter<U> {
613+
static getInstance<U>(
614+
firestore: Firestore,
615+
converter: PublicFirestoreDataConverter<U>
616+
): FirestoreDataConverter<U> {
597617
const converterMapByFirestore = FirestoreDataConverter.INSTANCES;
598618
let untypedConverterByConverter = converterMapByFirestore.get(firestore);
599619
if (!untypedConverterByConverter) {
@@ -603,7 +623,11 @@ class FirestoreDataConverter<U> extends Compat<PublicFirestoreDataConverter<U>>
603623

604624
let instance = untypedConverterByConverter.get(converter);
605625
if (!instance) {
606-
instance = new FirestoreDataConverter(firestore, new UserDataWriter(firestore), converter);
626+
instance = new FirestoreDataConverter(
627+
firestore,
628+
new UserDataWriter(firestore),
629+
converter
630+
);
607631
untypedConverterByConverter.set(converter, instance);
608632
}
609633

@@ -809,7 +833,12 @@ export class DocumentReference<T = PublicDocumentData>
809833
withConverter<U>(
810834
converter: PublicFirestoreDataConverter<U>
811835
): PublicDocumentReference<U> {
812-
return new DocumentReference<U>(this.firestore, this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter)));
836+
return new DocumentReference<U>(
837+
this.firestore,
838+
this._delegate.withConverter(
839+
FirestoreDataConverter.getInstance(this.firestore, converter)
840+
)
841+
);
813842
}
814843
}
815844

@@ -1113,7 +1142,12 @@ export class Query<T = PublicDocumentData>
11131142
}
11141143

11151144
withConverter<U>(converter: PublicFirestoreDataConverter<U>): Query<U> {
1116-
return new Query<U>(this.firestore, this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter)));
1145+
return new Query<U>(
1146+
this.firestore,
1147+
this._delegate.withConverter(
1148+
FirestoreDataConverter.getInstance(this.firestore, converter)
1149+
)
1150+
);
11171151
}
11181152
}
11191153

@@ -1252,7 +1286,12 @@ export class CollectionReference<T = PublicDocumentData>
12521286
withConverter<U>(
12531287
converter: PublicFirestoreDataConverter<U>
12541288
): CollectionReference<U> {
1255-
return new CollectionReference<U>(this.firestore, this._delegate.withConverter(FirestoreDataConverter.getInstance(this.firestore, converter)));
1289+
return new CollectionReference<U>(
1290+
this.firestore,
1291+
this._delegate.withConverter(
1292+
FirestoreDataConverter.getInstance(this.firestore, converter)
1293+
)
1294+
);
12561295
}
12571296
}
12581297

packages/firestore/test/integration/api/database.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,11 @@ apiDescribe('Database', (persistence: boolean) => {
13261326
// only to web.
13271327
apiDescribe('withConverter() support', (persistence: boolean) => {
13281328
class Post {
1329-
constructor(readonly title: string, readonly author: string, readonly ref: firestore.DocumentReference | null = null) {}
1329+
constructor(
1330+
readonly title: string,
1331+
readonly author: string,
1332+
readonly ref: firestore.DocumentReference | null = null
1333+
) {}
13301334
byline(): string {
13311335
return this.title + ', by ' + this.author;
13321336
}

0 commit comments

Comments
 (0)