Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore: update firestore-types with breaking API changes for FirestoreDataConverter #7423

Merged
merged 5 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading