Skip to content

Commit

Permalink
Firestore: update firestore-types with breaking API changes for Fires…
Browse files Browse the repository at this point in the history
…toreDataConverter (#7423)
  • Loading branch information
dconeybe authored Jul 6, 2023
1 parent f3067f7 commit 47860fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/empty-boats-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@firebase/firestore-types': major
'firebase': major
---

Update to be consistent with the FirestoreDataConverter changes from #7310
32 changes: 24 additions & 8 deletions packages/firestore-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ export interface GetOptions {
readonly source?: 'default' | 'server' | 'cache';
}

export class DocumentReference<T = DocumentData> {
export class DocumentReference<
T = DocumentData,
T2 extends DocumentData = DocumentData
> {
private constructor();

readonly id: string;
Expand Down Expand Up @@ -307,7 +310,10 @@ export interface SnapshotMetadata {
isEqual(other: SnapshotMetadata): boolean;
}

export class DocumentSnapshot<T = DocumentData> {
export class DocumentSnapshot<
T = DocumentData,
T2 extends DocumentData = DocumentData
> {
protected constructor();

readonly exists: boolean;
Expand All @@ -323,8 +329,9 @@ export class DocumentSnapshot<T = DocumentData> {
}

export class QueryDocumentSnapshot<
T = DocumentData
> extends DocumentSnapshot<T> {
T = DocumentData,
T2 extends DocumentData = DocumentData
> extends DocumentSnapshot<T, T2> {
private constructor();

data(options?: SnapshotOptions): T;
Expand All @@ -344,7 +351,7 @@ export type WhereFilterOp =
| 'array-contains-any'
| 'not-in';

export class Query<T = DocumentData> {
export class Query<T = DocumentData, T2 extends DocumentData = DocumentData> {
protected constructor();

readonly firestore: FirebaseFirestore;
Expand Down Expand Up @@ -409,7 +416,10 @@ export class Query<T = DocumentData> {
withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
}

export class QuerySnapshot<T = DocumentData> {
export class QuerySnapshot<
T = DocumentData,
T2 extends DocumentData = DocumentData
> {
private constructor();

readonly query: Query<T>;
Expand All @@ -430,14 +440,20 @@ export class QuerySnapshot<T = DocumentData> {

export type DocumentChangeType = 'added' | 'removed' | 'modified';

export interface DocumentChange<T = DocumentData> {
export interface DocumentChange<
T = DocumentData,
T2 extends DocumentData = DocumentData
> {
readonly type: DocumentChangeType;
readonly doc: QueryDocumentSnapshot<T>;
readonly oldIndex: number;
readonly newIndex: number;
}

export class CollectionReference<T = DocumentData> extends Query<T> {
export class CollectionReference<
T = DocumentData,
T2 extends DocumentData = DocumentData
> extends Query<T, T2> {
private constructor();

readonly id: string;
Expand Down

0 comments on commit 47860fe

Please sign in to comment.