@@ -322,7 +322,7 @@ export function createFirebaseInstance(
322322 * @param [storeKey='store'] - Name of redux store which contains
323323 * Firebase state (state.firebase)
324324 */
325- export function createFirebaseConnect ( storeKey : string ) : firebaseConnect
325+ export function createFirebaseConnect ( storeKey : string ) : typeof firebaseConnect
326326
327327/**
328328 * Function that creates a Higher Order Component which
@@ -333,11 +333,25 @@ export function createFirebaseConnect(storeKey: string): firebaseConnect
333333 * @param {String } [storeKey='store'] - Name of redux store which contains
334334 * Firebase state (state.firebase)
335335 */
336- export function createFirestoreConnect ( storeKey : string ) : firestoreConnect
336+ export function createFirestoreConnect ( storeKey : string ) : typeof firestoreConnect
337337
338- export function createWithFirebase ( storeKey : string ) : withFirebase
338+ export function createWithFirebase ( storeKey : string ) : typeof withFirebase
339+
340+ export function createWithFirestore ( storeKey : string ) : typeof withFirestore
341+
342+ export type QueryParamOption = 'orderByKey' | 'orderByChild' | 'orderByPriority' | 'limitToFirst' | 'limitToLast' | 'notParsed' | 'parsed'
343+
344+ export type QueryParamOptions = QueryParamOption | string [ ]
345+
346+ export interface ReactReduxFirebaseQuerySetting {
347+ path : string
348+ type ?: 'value' | 'once' | 'child_added' | 'child_removed' | 'child_changed' | 'child_moved'
349+ queryParams ?: QueryParamOptions
350+ storeAs ?: string
351+ }
352+
353+ export type ReactReduxFirebaseQueries = ( ReactReduxFirebaseQuerySetting | string ) [ ]
339354
340- export function createWithFirestore ( storeKey : string ) : withFirestore
341355
342356// https://github.com/prescottprue/redux-firestore#query-options
343357type WhereOptions = [ string , FirestoreTypes . WhereFilterOp , any ]
@@ -347,13 +361,13 @@ type OrderByOptions = [string, FirestoreTypes.OrderByDirection]
347361 * Options which can be passed to firestore query through
348362 * redux-firestore or react-redux-firebase
349363 */
350- export interface FirestoreQueryOptions {
364+ export interface ReduxFirestoreQuerySetting {
351365 // https://github.com/prescottprue/redux-firestore#collection
352366 collection : string
353367 // https://github.com/prescottprue/redux-firestore#document
354368 doc ?: string
355369 // https://github.com/prescottprue/redux-firestore#sub-collections
356- subcollections ?: FirestoreQueryOptions [ ]
370+ subcollections ?: ReduxFirestoreQuerySetting [ ]
357371 // https://github.com/prescottprue/redux-firestore#where
358372 where ?: WhereOptions | WhereOptions [ ]
359373 // https://github.com/prescottprue/redux-firestore#orderby
@@ -372,45 +386,48 @@ export interface FirestoreQueryOptions {
372386 endBefore ?: FirestoreTypes . DocumentSnapshot | any | any [ ]
373387}
374388
389+ export type ReduxFirestoreQueries = ( ReduxFirestoreQuerySetting | string ) [ ]
390+
391+
375392/**
376393 * Firestore instance extended with methods which dispatch redux actions.
377394 * More info available in the [API section of the redux-firestore docs](https://github.com/prescottprue/redux-firestore#api).
378395 */
379396interface ExtendedFirestoreInstance extends FirestoreTypes . FirebaseFirestore {
380397 // Get data from firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#get).
381- get : ( docPath : string | FirestoreQueryOptions ) => Promise < void >
398+ get : ( docPath : string | ReduxFirestoreQuerySetting ) => Promise < void >
382399
383400 // Set data to firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#set).
384- set : ( docPath : string | FirestoreQueryOptions , data : Object ) => Promise < void >
401+ set : ( docPath : string | ReduxFirestoreQuerySetting , data : Object ) => Promise < void >
385402
386403 // https://github.com/prescottprue/redux-firestore#add
387404 add : (
388- collectionPath : string | FirestoreQueryOptions ,
405+ collectionPath : string | ReduxFirestoreQuerySetting ,
389406 data : Object
390407 ) => Promise < { id : string } >
391408
392409 // https://github.com/prescottprue/redux-firestore#update
393410 update : (
394- docPath : string | FirestoreQueryOptions ,
411+ docPath : string | ReduxFirestoreQuerySetting ,
395412 data : Object
396413 ) => Promise < void >
397414
398415 // https://github.com/prescottprue/redux-firestore#delete
399- delete : ( docPath : string | FirestoreQueryOptions ) => void
416+ delete : ( docPath : string | ReduxFirestoreQuerySetting ) => void
400417
401418 // https://github.com/prescottprue/redux-firestore#runtransaction
402- runTransaction : ( transaction : WithFirestoreProps [ 'firestore' ] ) => Promise < any >
419+ // runTransaction: (transaction: WithFirestoreProps['firestore']) => Promise<any>
403420
404421 // https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener
405- onSnapshot : ( options : FirestoreQueryOptions ) => Promise < void >
406- setListener : ( options : FirestoreQueryOptions ) => Promise < void >
422+ onSnapshot : ( options : ReduxFirestoreQuerySetting ) => Promise < void >
423+ setListener : ( options : ReduxFirestoreQuerySetting ) => Promise < void >
407424
408425 //https://github.com/prescottprue/redux-firestore#setlisteners
409- setListeners : ( optionsArray : FirestoreQueryOptions [ ] ) => Promise < void >
426+ setListeners : ( optionsArray : ReduxFirestoreQuerySetting [ ] ) => Promise < void >
410427
411428 // https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlisteners
412- unsetListener : ( options : FirestoreQueryOptions ) => void
413- unsetListeners : ( options : FirestoreQueryOptions [ ] ) => void
429+ unsetListener : ( options : ReduxFirestoreQuerySetting ) => void
430+ unsetListeners : ( options : ReduxFirestoreQuerySetting [ ] ) => void
414431}
415432
416433// https://github.com/prescottprue/redux-firestore#other-firebase-statics
@@ -439,15 +456,18 @@ export interface WithFirestoreProps {
439456 dispatch : Dispatch
440457}
441458
459+ interface CreateUserCredentials {
460+ email : string
461+ password : string
462+ signIn ?: boolean // default true
463+ }
464+
442465type Credentials =
443- | {
444- email : string
445- password : string
446- }
466+ | CreateUserCredentials
447467 | {
448468 provider : 'facebook' | 'google' | 'twitter'
449469 type : 'popup' | 'redirect'
450- scopes : string [ ]
470+ scopes ? : string [ ]
451471 }
452472 | AuthTypes . AuthCredential
453473 | {
@@ -459,12 +479,6 @@ type Credentials =
459479 applicationVerifier : AuthTypes . ApplicationVerifier
460480 }
461481
462- interface CreateUserCredentials {
463- email : string
464- password : string
465- signIn ?: boolean // default true
466- }
467-
468482interface UserProfile {
469483 email : string
470484 username : string
@@ -572,7 +586,7 @@ export interface WithFirebaseProps<ProfileType> {
572586 * React HOC that attaches/detaches Firebase Real Time Database listeners on mount/unmount
573587 */
574588export function firebaseConnect < ProfileType , TInner = { } > (
575- connect ?: mapper < TInner , string [ ] > | string [ ]
589+ connect ?: mapper < TInner , ReactReduxFirebaseQueries > | ReactReduxFirebaseQueries
576590) : InferableComponentEnhancerWithProps <
577591 TInner & WithFirebaseProps < ProfileType > ,
578592 WithFirebaseProps < ProfileType >
@@ -594,10 +608,7 @@ export function firebaseStateReducer(...args: any[]): FirestoreReducer.Reducer
594608 * React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount
595609 */
596610export function firestoreConnect < TInner = { } > (
597- connect ?:
598- | mapper < TInner , ( string | FirestoreQueryOptions ) [ ] >
599- | FirestoreQueryOptions [ ]
600- | string [ ]
611+ connect ?: mapper < TInner , ReduxFirestoreQueries > | ReduxFirestoreQueries
601612) : InferableComponentEnhancerWithProps <
602613 TInner & WithFirestoreProps ,
603614 WithFirestoreProps
@@ -629,6 +640,17 @@ export function isLoaded(...args: any[]): boolean
629640 */
630641export function useFirebase ( ) : ExtendedFirebaseInstance
631642
643+ /**
644+ * React hook that automatically listens/unListens
645+ * to provided Cloud Firestore paths. Make sure you have required/imported
646+ * Cloud Firestore, including it's reducer, before attempting to use.
647+ * @param queriesConfig - An object or string for paths to sync
648+ * from firestore. Can also be a function that returns the object or string.
649+ */
650+ export function useFirebaseConnect < TInner > (
651+ connect ?: mapper < TInner , ReactReduxFirebaseQueries > | ReactReduxFirebaseQueries
652+ ) : void
653+
632654/**
633655 * React hook that return firestore object.
634656 * Firestore instance is gathered from `store.firestore`, which is attached
@@ -644,10 +666,10 @@ export function useFirestore(): ExtendedFirestoreInstance
644666 * @param queriesConfig - An object or string for paths to sync
645667 * from firestore. Can also be a function that returns the object or string.
646668 */
647- export function useFirestoreConnect (
669+ export function useFirestoreConnect < TInner > (
648670 connect ?:
649- | mapper < TInner , ( string | FirestoreQueryOptions ) [ ] >
650- | FirestoreQueryOptions [ ]
671+ | mapper < TInner , ( string | ReduxFirestoreQuerySetting ) [ ] >
672+ | ReduxFirestoreQuerySetting [ ]
651673 | string [ ]
652674) : void
653675
@@ -674,7 +696,7 @@ export interface ReactReduxFirebaseProviderProps {
674696 config : Partial < ReactReduxFirebaseConfig >
675697 dispatch : Dispatch
676698 children ?: React . ReactNode
677- initalizeAuth ?: boolean
699+ initializeAuth ?: boolean
678700 createFirestoreInstance ?: (
679701 firebase : typeof Firebase ,
680702 configs : Partial < ReduxFirestoreConfig > ,
@@ -759,7 +781,7 @@ export interface ReduxFirestoreProviderProps {
759781 dispatch : Dispatch
760782 ) => object
761783 children ?: React . ReactNode
762- initalizeAuth ?: boolean
784+ initializeAuth ?: boolean
763785}
764786
765787/**
@@ -774,7 +796,7 @@ export function ReduxFirestoreProvider(props: ReduxFirestoreProviderProps): any
774796 */
775797export function withFirebase < P extends object > (
776798 componentToWrap : React . ComponentType < P >
777- ) : React . FC < P & WithFirebaseProps >
799+ ) : React . FC < P & WithFirebaseProps < P > >
778800
779801/**
780802 * React Higher Order Component that passes firestore as a prop (comes from context.store.firestore)
@@ -784,14 +806,6 @@ export function withFirestore<P extends object>(
784806 componentToWrap : React . ComponentType < P >
785807) : React . FC < P & WithFirestoreProps >
786808
787- export namespace withFirebase {
788- const prototype : { }
789- }
790-
791- export namespace withFirestore {
792- const prototype : { }
793- }
794-
795809export namespace authIsReady {
796810 const prototype : { }
797811}
@@ -884,7 +898,7 @@ export namespace FirestoreReducer {
884898 }
885899 listeners : Listeners
886900 ordered : Ordered < any >
887- queries : Data < FirestoreQueryOptions & ( Dictionary < any > | any ) >
901+ queries : Data < ReduxFirestoreQuerySetting & ( Dictionary < any > | any ) >
888902 status : {
889903 requested : Dictionary < boolean >
890904 requesting : Dictionary < boolean >
0 commit comments