diff --git a/index.d.ts b/index.d.ts index 00c0400ea..89dd2e33e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,6 +10,8 @@ import { Dispatch } from 'redux' */ type Omit = Pick> +type FileOrBlob = T extends File ? File : Blob + /** * Injects props and removes them from the prop requirements. * Will not pass through the injected props if they are passed in during @@ -738,11 +740,11 @@ interface ExtendedStorageInstance { * @param options.documentId - Id of document to update with metadata if using Firestore * @see https://react-redux-firebase.com/docs/api/storage.html#uploadFile */ - uploadFile: ( + uploadFile: ( path: string, - file: File | Blob, + file: FileOrBlob, dbPath?: string, - options?: UploadFileOptions + options?: UploadFileOptions ) => Promise<{ uploadTaskSnapshot: StorageTypes.UploadTaskSnapshot }> /** @@ -758,42 +760,46 @@ interface ExtendedStorageInstance { * @param options.documentId - Id of document to update with metadata if using Firestore * @see https://react-redux-firebase.com/docs/api/storage.html#uploadFiles */ - uploadFiles: ( + uploadFiles: ( path: string, - files: File[] | Blob[], + files: FileOrBlob[], dbPath?: string, - options?: UploadFileOptions + options?: UploadFileOptions ) => Promise<{ uploadTaskSnapshot: StorageTypes.UploadTaskSnapshot }[]> } /** * Configuration object passed to uploadFile and uploadFiles functions */ -export interface UploadFileOptions { - name?: string | (( - file: File | Blob, - internalFirebase: WithFirebaseProps['firebase'], - uploadConfig: { - path: string, - file: File | Blob, - dbPath?: string, - options?: UploadFileOptions - } - ) => string) - documentId?: string | (( - uploadRes: StorageTypes.UploadTaskSnapshot, - firebase: WithFirebaseProps['firebase'], - metadata: StorageTypes.UploadTaskSnapshot['metadata'], - downloadURL: string - ) => string) +export interface UploadFileOptions { + name?: + | string + | (( + file: FileOrBlob, + internalFirebase: WithFirebaseProps['firebase'], + uploadConfig: { + path: string + file: FileOrBlob + dbPath?: string + options?: UploadFileOptions + } + ) => string) + documentId?: + | string + | (( + uploadRes: StorageTypes.UploadTaskSnapshot, + firebase: WithFirebaseProps['firebase'], + metadata: StorageTypes.UploadTaskSnapshot['metadata'], + downloadURL: string + ) => string) useSetForMetadata?: boolean metadata?: StorageTypes.UploadMetadata - metadataFactory? : (( + metadataFactory?: ( uploadRes: StorageTypes.UploadTaskSnapshot, firebase: WithFirebaseProps['firebase'], metadata: StorageTypes.UploadTaskSnapshot['metadata'], downloadURL: string - ) => object) + ) => object } export interface WithFirebaseProps { @@ -1032,11 +1038,20 @@ interface ReactReduxFirebaseConfig { /** * Function for changing how profile is written to database (both RTDB and Firestore). */ - profileFactory?: (userData?: AuthTypes.User, profileData?: any, firebase?: WithFirebaseProps['firebase']) => Promise | any + profileFactory?: ( + userData?: AuthTypes.User, + profileData?: any, + firebase?: WithFirebaseProps['firebase'] + ) => Promise | any /** * Function that returns that meta data object stored after a file is uploaded (both RTDB and Firestore). */ - fileMetadataFactory?: (uploadRes: StorageTypes.UploadTaskSnapshot, firebase: WithFirebaseProps['firebase'], metadata: StorageTypes.UploadTaskSnapshot.metadata, downloadURL: string) => object + fileMetadataFactory?: ( + uploadRes: StorageTypes.UploadTaskSnapshot, + firebase: WithFirebaseProps['firebase'], + metadata: StorageTypes.UploadTaskSnapshot.metadata, + downloadURL: string + ) => object } /**