invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.72k stars 2.22k forks source link

[🐛] 🔥Firestore document get string type is incorrect when using interface #7592

Closed ChromeQ closed 9 months ago

ChromeQ commented 10 months ago

Issue

I am getting typescript errors with the following snippet:

interface Foo {
  coords: {
    latitude: number;
    longitude: number;
  };
}
const foo = await firestore.collection<Foo>('foo').get(); // returns `FirebaseFirestoreTypes.QuerySnapshot<Foo>`
foo.docs.map((snap) => snap.get('coords.latitude')); // throws TS error: Argument of type '"coords.latitude"' is not assignable to parameter of type 'FieldPath | "coords"'.ts(2345)

Similar to #7147 the types are just not correct - unfortunately I missed this one as part of my PR #7570 - Opening this issue to track an upcoming PR


Project Files

Javascript

Click To Expand

#### `package.json`: ```json "dependencies": { "@react-native-firebase/app": "18.8.0", "@react-native-firebase/firestore": "18.8.0", } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [x] I'm not using Pods - [ ] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` ❯ npx react-native info info Fetching system and libraries information... System: OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish) CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1270P Memory: 24.25 GB / 30.78 GB Shell: version: 5.1.16 path: /bin/bash Binaries: Node: version: 18.19.0 path: ~/.nvm/versions/node/v18.19.0/bin/node Yarn: version: 1.22.19 path: ~/.yarn/bin/yarn npm: version: 10.2.3 path: ~/.nvm/versions/node/v18.19.0/bin/npm Watchman: Not Found SDKs: Android SDK: Android NDK: 25.2.9519653 IDEs: Android Studio: Not Found Languages: Java: version: 17.0.9 path: /usr/bin/javac Ruby: Not Found npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.73.2 wanted: 0.73.2 npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: Not found newArchEnabled: Not found iOS: hermesEnabled: Not found newArchEnabled: Not found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `18.8.0` - **`Firebase` module(s) you're using that has the issue:** - `firestore` - **Are you using `TypeScript`?** - `Y` & `5.3.3`


ChromeQ commented 10 months ago

@mikehardy Hopefully another quick fix similar to my other one last week. Cheers