Skip to content

Commit fa060c9

Browse files
Add type to DocumentReference/CollectionReference/Query
1 parent b07f822 commit fa060c9

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

packages/firestore/exp/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export type SetOptions =
232232

233233
export class DocumentReference<T = DocumentData> {
234234
private constructor();
235+
readonly type: 'document';
235236
readonly id: string;
236237
readonly firestore: FirebaseFirestore;
237238
readonly path: string;
@@ -272,6 +273,7 @@ export type WhereFilterOp =
272273

273274
export class Query<T = DocumentData> {
274275
protected constructor();
276+
readonly type: 'query' | 'collection';
275277
readonly firestore: FirebaseFirestore;
276278
where(
277279
fieldPath: string | FieldPath,
@@ -320,6 +322,7 @@ export interface DocumentChange<T = DocumentData> {
320322

321323
export class CollectionReference<T = DocumentData> extends Query<T> {
322324
private constructor();
325+
readonly type: 'collection';
323326
readonly id: string;
324327
readonly path: string;
325328
withConverter<U>(

packages/firestore/lite/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export type SetOptions =
193193

194194
export class DocumentReference<T = DocumentData> {
195195
private constructor();
196+
readonly type: 'document';
196197
readonly id: string;
197198
readonly firestore: FirebaseFirestore;
198199
readonly path: string;
@@ -227,6 +228,7 @@ export type WhereFilterOp =
227228

228229
export class Query<T = DocumentData> {
229230
protected constructor();
231+
readonly type: 'query' | 'collection';
230232
readonly firestore: FirebaseFirestore;
231233
where(
232234
fieldPath: string | FieldPath,
@@ -264,6 +266,7 @@ export class QuerySnapshot<T = DocumentData> {
264266

265267
export class CollectionReference<T = DocumentData> extends Query<T> {
266268
private constructor();
269+
readonly type: 'collection';
267270
readonly id: string;
268271
readonly path: string;
269272
withConverter<U>(

packages/firestore/lite/src/api/reference.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ import { Code, FirestoreError } from '../../../src/util/error';
7474
export class DocumentReference<T = firestore.DocumentData>
7575
extends DocumentKeyReference<T>
7676
implements firestore.DocumentReference<T> {
77+
readonly type = 'document';
78+
7779
constructor(
7880
readonly firestore: Firestore,
7981
key: DocumentKey,
@@ -99,6 +101,8 @@ export class DocumentReference<T = firestore.DocumentData>
99101

100102
export class Query<T = firestore.DocumentData> extends BaseQuery
101103
implements firestore.Query<T> {
104+
readonly type: 'query' | 'collection' = 'query';
105+
102106
// This is the lite version of the Query class in the main SDK.
103107
constructor(
104108
readonly firestore: Firestore,
@@ -256,6 +260,8 @@ export class Query<T = firestore.DocumentData> extends BaseQuery
256260

257261
export class CollectionReference<T = firestore.DocumentData> extends Query<T>
258262
implements firestore.CollectionReference<T> {
263+
readonly type = 'collection';
264+
259265
constructor(
260266
readonly firestore: Firestore,
261267
readonly _path: ResourcePath,

0 commit comments

Comments
 (0)