Repository navigation
Is it possible to inject react native firebase ataptor? #45
Description
Activity
Hey! That's an interesting problem. I never considered React Native but now it makes sense. It looks like React Native supports the
react-nativefield inpackage.jsonso I can add a special adaptor for it.@pie6k I've added experimental React Native adaptor #46 but can't build it as TypeScript detects a dozen of type errors in the
@react-native-firebase/firestoretype definitions. I'm wondering if you use it with TypeScript and if so, do you have such issues:Show errors
node_modules/@react-native-firebase/app/lib/index.d.ts:395:3 - error TS2666: Exports and export assignments are not permitted in module augmentations. 395 export default module; ~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:124:32 - error TS2304: Cannot find name 'value'. 124 add(data: { [key: string]: value }): Promise<DocumentReference>; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:425:32 - error TS2304: Cannot find name 'value'. 425 set(data: { [key: string]: value }, options?: SetOptions): Promise<void>; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:444:35 - error TS2304: Cannot find name 'value'. 444 update(data: { [key: string]: value }): Promise<void>; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:505:30 - error TS2304: Cannot find name 'value'. 505 data(): { [key: string]: value } | undefined; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:566:30 - error TS2304: Cannot find name 'value'. 566 data(): { [key: string]: value }; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1573:30 - error TS2304: Cannot find name 'value'. 1573 data: { [key: string]: value }, ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1598:67 - error TS2304: Cannot find name 'value'. 1598 update(documentRef: DocumentReference, data: { [key: string]: value }): Transaction; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1699:30 - error TS2304: Cannot find name 'value'. 1699 data: { [key: string]: value }, ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1720:67 - error TS2304: Cannot find name 'value'. 1720 update(documentRef: DocumentReference, data: { [key: string]: value }): WriteBatch; ~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1924:66 - error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). 1924 runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise<any>; ~~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1947:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. 1947 import { ReactNativeFirebase } from '@react-native-firebase/app'; ~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1948:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. 1948 import ReactNativeFirebaseModule = ReactNativeFirebase.Module; ~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1949:3 - error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module. 1949 import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; ~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1952:27 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. 1952 export const firebase = firebaseNamedExport; ~~~~~~~~~~~~~~~~~~~ node_modules/@react-native-firebase/firestore/lib/index.d.ts:1958:3 - error TS2666: Exports and export assignments are not permitted in module augmentations. 1958 export default defaultExport; ~~~~~~ Found 16 errors.Ok, I've figured that they have buggy definitions, but I managed to disable those and released
typesaurus@6.1.0-alpha.1.@pie6k could please test it and see if it works. It supposed to work out-of-the-box without injecting the adaptor.
Reacted by Calvin ChengI'll try to play with it a bit later.
I've also added a few comments to #46 that might simplify it a bit.
Reacted by Sasha Koss, Calvin Cheng and Tuan NguyenI'm not sure what the state of React Native and Firebase is, but I can see that people use Firebase Web SDK. If someone needs React Native Firebase package adaptor, please open a new issue with more details about why an adaptor is needed.
I've tried to check adaptor module, but it seems adaptors for browser and node are hardcoded there. Even if I can inject adaptor into
nodeadaptor, the one fromgoogleis still imported there so I'd have to have it installed in my react native project.React Native Firebase is trying to have the same JS API as browser one
https://rnfirebase.io/firestore/usage