Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Extract optional firebase plugins
Co-authored-by: Chris Serino <[email protected]>
  • Loading branch information
msutkowski and themindoverall committed Jun 5, 2020
commit 87f59028a5c67448fbca58562781f9a984df185e
26 changes: 25 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import { FirebaseNamespace } from "@firebase/app-types";
import * as FirestoreTypes from '@firebase/firestore-types'
import * as DatabaseTypes from '@firebase/database-types'
import * as StorageTypes from '@firebase/storage-types'
Expand Down Expand Up @@ -160,7 +161,7 @@ interface FirebaseDatabaseService {
* redux actions.
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html
*/
interface ExtendedFirebaseInstance
interface BaseExtendedFirebaseInstance
extends DatabaseTypes.FirebaseDatabase,
FirebaseDatabaseService,
ExtendedAuthInstance,
Expand Down Expand Up @@ -338,6 +339,29 @@ interface ExtendedFirebaseInstance
) => Promise<any>
}

/**
* OptionalOverride is left here in the event that any of the optional properties below need to be extended in the future.
* Example: OptionalOverride<FirebaseNamespace, 'messaging', { messaging: ExtendedMessagingInstance }>
*/
type OptionalOverride<T, b extends string, P> = b extends keyof T ? P : {};
type OptionalPick<T, b extends string> = { [k in (b extends keyof T ? b : never)]: T[k] };

type ExtendedFirebaseInstance = BaseExtendedFirebaseInstance & OptionalPick<FirebaseNamespace, 'messaging' | 'performance' | 'functions' | 'analytics' | 'remoteConfig'>

/**
* Create an extended firebase instance that has methods attached
* which dispatch redux actions.
* @param firebase - Firebase instance which to extend
* @param configs - Configuration object
* @param dispatch - Action dispatch function
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html
*/
export function createFirebaseInstance(
firebase: FirebaseNamespace,
configs: Partial<ReduxFirestoreConfig>,
dispatch: Dispatch
): ExtendedFirebaseInstance;

/**
* Create an extended firebase instance that has methods attached
* which dispatch redux actions.
Expand Down