diff --git a/src/index.d.ts b/src/index.d.ts index 9242c786..d2f6bc8e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -53,7 +53,10 @@ declare module 'react-native-firebase' { RNFirebase.notifications.NotificationsStatics >; type PerfModule = FirebaseModuleAndStatics; - type StorageModule = FirebaseModuleAndStatics; + type StorageModule = FirebaseModuleAndStatics< + RNFirebase.storage.Storage, + RNFirebase.storage.StorageStatics + >; // type UtilsModule: FirebaseModuleAndStatics; // Modules commented-out do not currently have type definitions @@ -713,7 +716,7 @@ declare module 'react-native-firebase' { /** * Sets multiple user properties to the supplied values. */ - setUserProperties(fieldMapping: {[key: string]: string | null}): void; + setUserProperties(fieldMapping: { [key: string]: string | null }): void; [key: string]: any; } @@ -2417,7 +2420,7 @@ declare module 'react-native-firebase' { namespace DocumentReference { type ObserverOnNext = (documentSnapshot: DocumentSnapshot) => void; - type ObserverOnError = (err: object) => void; + type ObserverOnError = (err: Query.SnapshotError) => void; interface Observer { next: ObserverOnNext; @@ -2573,8 +2576,20 @@ declare module 'react-native-firebase' { startAt?: any[]; } + interface NativeError extends Error { + code: string; + message: string; + nativeErrorCode?: string; + nativeErrorMessage?: string; + } + + interface SnapshotError extends NativeError { + path: string; + appName: string; + } + type ObserverOnNext = (querySnapshot: QuerySnapshot) => void; - type ObserverOnError = (err: object) => void; + type ObserverOnError = (err: SnapshotError) => void; interface Observer { next: ObserverOnNext; @@ -2906,6 +2921,7 @@ declare module 'react-native-firebase/firestore' { export type GeoPoint = RNFirebase.firestore.GeoPoint; export type Path = RNFirebase.firestore.Path; export type Query = RNFirebase.firestore.Query; + export type SnapshotError = RNFirebase.firestore.Query.SnapshotError; export type QuerySnapshot = RNFirebase.firestore.QuerySnapshot; export type WriteBatch = RNFirebase.firestore.WriteBatch; } diff --git a/src/modules/firestore/DocumentReference.js b/src/modules/firestore/DocumentReference.js index 7177a776..48f6054c 100644 --- a/src/modules/firestore/DocumentReference.js +++ b/src/modules/firestore/DocumentReference.js @@ -21,7 +21,7 @@ import type { import type Path from './Path'; import type { NativeErrorResponse } from '../../common/commonTypes.flow'; -type ObserverOnError = Object => void; +type ObserverOnError = SnapshotError => void; type ObserverOnNext = DocumentSnapshot => void; type Observer = {