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

little fix for an error #3326

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
81 changes: 33 additions & 48 deletions src/compat/firestore/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,47 @@
import { Subscriber } from 'rxjs';
import firebase from 'firebase/compat/app';

export type Settings = firebase.firestore.Settings;
export type CollectionReference<T = DocumentData> = firebase.firestore.CollectionReference<T>;
export type DocumentReference<T = DocumentData> = firebase.firestore.DocumentReference<T>;
export type PersistenceSettings = firebase.firestore.PersistenceSettings;
export type DocumentChangeType = firebase.firestore.DocumentChangeType;
export type SnapshotOptions = firebase.firestore.SnapshotOptions;
export type FieldPath = firebase.firestore.FieldPath;
export type Query<T = DocumentData> = firebase.firestore.Query<T>;

export type SetOptions = firebase.firestore.SetOptions;
export type DocumentData = firebase.firestore.DocumentData;

export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
readonly exists: true;
data(options?: SnapshotOptions): T;
export declare type Settings = firebase.firestore.Settings;
export declare type CollectionReference<T = DocumentData> = firebase.firestore.CollectionReference<T>;
export declare type DocumentReference<T = DocumentData> = firebase.firestore.DocumentReference<T>;
export declare type PersistenceSettings = firebase.firestore.PersistenceSettings;
export declare type DocumentChangeType = firebase.firestore.DocumentChangeType;
export declare type SnapshotOptions = firebase.firestore.SnapshotOptions;
export declare type FieldPath = firebase.firestore.FieldPath;
export declare type Query<T = DocumentData> = firebase.firestore.Query<T>;
export declare type SetOptions = firebase.firestore.SetOptions;
export declare type DocumentData = firebase.firestore.DocumentData;
export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot<T> {
readonly exists: true;
data(options?: SnapshotOptions): T;
}

export interface DocumentSnapshotDoesNotExist extends firebase.firestore.DocumentSnapshot {
readonly exists: false;
data(options?: SnapshotOptions): undefined;
get(fieldPath: string | FieldPath, options?: SnapshotOptions): undefined;
readonly exists: false;
data(options?: SnapshotOptions): undefined;
get(fieldPath: string | FieldPath, options?: SnapshotOptions): undefined;
}

export type DocumentSnapshot<T> = DocumentSnapshotExists<T> | DocumentSnapshotDoesNotExist;

export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {
data(options?: SnapshotOptions): T;
export declare type DocumentSnapshot<T> = DocumentSnapshotExists<T> | DocumentSnapshotDoesNotExist;
export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot<T> {
data(options?: SnapshotOptions): T;
}

export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {
readonly docs: QueryDocumentSnapshot<T>[];
export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot<T> {
readonly docs: QueryDocumentSnapshot<T>[];
}

export interface DocumentChange<T> extends firebase.firestore.DocumentChange {
readonly doc: QueryDocumentSnapshot<T>;
export interface DocumentChange<T> extends firebase.firestore.DocumentChange<T> {
readonly doc: QueryDocumentSnapshot<T>;
}

export interface DocumentChangeAction<T> {
type: DocumentChangeType;
payload: DocumentChange<T>;
type: DocumentChangeType;
payload: DocumentChange<T>;
}

export interface Action<T> {
type: string;
payload: T;
type: string;
payload: T;
}

export interface Reference<T> {
onSnapshot: (options: firebase.firestore.SnapshotListenOptions, sub: Subscriber<any>) => any;
onSnapshot: (options: firebase.firestore.SnapshotListenOptions, sub: Subscriber<any>) => any;
}

// A convience type for making a query.
// Example: const query = (ref) => ref.where('name', == 'david');
export type QueryFn<T = DocumentData> = (ref: CollectionReference<T>) => Query<T>;

export type QueryGroupFn<T = DocumentData> = (query: Query<T>) => Query<T>;

export declare type QueryFn<T = DocumentData> = (ref: CollectionReference<T>) => Query<T>;
export declare type QueryGroupFn<T = DocumentData> = (query: Query<T>) => Query<T>;
/**
* A structure that provides an association between a reference
* and a query on that reference. Note: Performing operations
Expand All @@ -81,6 +65,7 @@ export type QueryGroupFn<T = DocumentData> = (query: Query<T>) => Query<T>;
* });
*/
export interface AssociatedReference<T = DocumentData> {
ref: CollectionReference<T>;
query: Query<T>;
ref: CollectionReference<T>;
query: Query<T>;
}