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

Add firestore reducer for typescript #296

Closed
Closed
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
32 changes: 30 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export interface Config {
preserveOnListenerError: null | object;

// https://github.com/prescottprue/redux-firestore#onattemptcollectiondelete
onAttemptCollectionDelete: null | ((queryOption: string, dispatch: Dispatch, firebase: Object) => void);
onAttemptCollectionDelete:
| null
| ((queryOption: string, dispatch: Dispatch, firebase: Object) => void);

// https://github.com/prescottprue/redux-firestore#mergeordered
mergeOrdered: boolean;
Expand Down Expand Up @@ -127,10 +129,36 @@ export function getFirestore(
otherConfig?: Partial<Config>,
): any;

export namespace FirestoreReducer {
export interface Reducer<Schema extends Record<string, any> = {}> {
composite?: Data<any | Dictionary<any>>;
data: { [T in keyof Schema]: Record<string, Schema[T]> };
errors: {
allIds: string[];
byQuery: any[];
};
listeners: Listeners;
ordered: {
[T in keyof Schema]: Array<Schema[T]>;
};
queries: Data<ReduxFirestoreQuerySetting & (Dictionary<any> | any)>;
status: {
requested: Dictionary<boolean>;
requesting: Dictionary<boolean>;
timestamps: Dictionary<number>;
};
}

const prototype: {};
}

/**
* A redux store reducer for Firestore state
*/
export function firestoreReducer(state: object, action: object): any;
export function firestoreReducer<Schema extends Record<string, any> = {}>(
state: any,
action: any,
): FirestoreReducer.Reducer;

/**
* Create a firestore instance that has helpers attached for dispatching actions
Expand Down