From 71c14c316fe0830bc1eaeb2b6ffb869650abaabf Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Tue, 19 Jan 2021 14:54:21 -0600 Subject: [PATCH] resolve comments --- packages/firebase/index.d.ts | 13 ++++++++++--- packages/firestore-types/index.d.ts | 8 +++++--- packages/firestore/src/lite/database.ts | 1 + packages/firestore/test/unit/api/database.test.ts | 3 --- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/firebase/index.d.ts b/packages/firebase/index.d.ts index c4ae7fb81e0..2a99c134cd0 100644 --- a/packages/firebase/index.d.ts +++ b/packages/firebase/index.d.ts @@ -8313,6 +8313,13 @@ declare namespace firebase.firestore { */ namedQuery(name: string): Promise | null>; + /** + * Returns a JSON-serializable representation of this object. + * + * @return A JSON-serializable representation of this object. + */ + toJSON(): Object; + /** * @hidden */ @@ -9172,9 +9179,9 @@ declare namespace firebase.firestore { * `exists` property will always be true and `data()` will never return * 'undefined'. */ - export class QueryDocumentSnapshot extends DocumentSnapshot< - T - > { + export class QueryDocumentSnapshot< + T = DocumentData + > extends DocumentSnapshot { private constructor(); /** diff --git a/packages/firestore-types/index.d.ts b/packages/firestore-types/index.d.ts index 9722edee019..1df12608a79 100644 --- a/packages/firestore-types/index.d.ts +++ b/packages/firestore-types/index.d.ts @@ -102,6 +102,8 @@ export class FirebaseFirestore { namedQuery(name: string): Promise | null>; + toJSON(): object; + INTERNAL: { delete: () => Promise }; } @@ -315,9 +317,9 @@ export class DocumentSnapshot { isEqual(other: DocumentSnapshot): boolean; } -export class QueryDocumentSnapshot extends DocumentSnapshot< - T -> { +export class QueryDocumentSnapshot< + T = DocumentData +> extends DocumentSnapshot { private constructor(); data(options?: SnapshotOptions): T; diff --git a/packages/firestore/src/lite/database.ts b/packages/firestore/src/lite/database.ts index 58a439d89bc..6ecb3d50647 100644 --- a/packages/firestore/src/lite/database.ts +++ b/packages/firestore/src/lite/database.ts @@ -136,6 +136,7 @@ export class FirebaseFirestore implements FirestoreService { toJSON(): object { return { + app: this.app.name, databaseId: this._databaseId, settings: this._settings }; diff --git a/packages/firestore/test/unit/api/database.test.ts b/packages/firestore/test/unit/api/database.test.ts index ee8cfac8b52..f01c5d509eb 100644 --- a/packages/firestore/test/unit/api/database.test.ts +++ b/packages/firestore/test/unit/api/database.test.ts @@ -83,9 +83,6 @@ describe('DocumentSnapshot', () => { it('JSON.stringify() does not throw', () => { JSON.stringify(documentSnapshot('foo/bar', { a: 1 }, true)); - JSON.stringify(documentSnapshot('foo/bar', { a: 1 }, false)); - JSON.stringify(documentSnapshot('foo/bar', null, true)); - JSON.stringify(documentSnapshot('foo/bar', null, false)); }); });