Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] Type mismatch between initializeApp return value and getAuth variable #8098

Open
1 of 10 tasks
aaroncraigongithub opened this issue Oct 29, 2024 · 3 comments
Open
1 of 10 tasks
Labels
Needs Attention tools: typings TypeScript / Flow type: bug New bug report

Comments

@aaroncraigongithub
Copy link

aaroncraigongithub commented Oct 29, 2024

Issue

The following code snippet triggers Typescript errors:

import { initializeApp } from "@react-native-firebase/app";
import { getAuth } from "@react-native-firebase/auth";

const firebaseConfig = { ... };
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

The issue is that initializeApp returns a ReactNativeFirebase.FirebaseApp while getAuth wants a FirebaseApp as defined in fiirebase/app-types.

The first has an extra utils() property, and is missing a required automaticDataCollectionEnabled property expected by the auth module.

This is in a ReactNative (expo) project, where I am building for both native and web.

Project Files

Javascript

Click To Expand

package.json:

    "@react-native-firebase/app": "^21.2.0",
    "@react-native-firebase/auth": "^21.2.0",
    "firebase": "^11.0.1",

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// 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:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • 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:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION


@aaroncraigongithub
Copy link
Author

I discovered that the following seems to solve the issue for now:

getAuth({ ...app, automaticDataCollectionEnabled: false });

@mikehardy mikehardy added the tools: typings TypeScript / Flow label Nov 5, 2024
Copy link

github-actions bot commented Dec 3, 2024

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 3, 2024
@mikehardy
Copy link
Collaborator

The first has an extra utils() property, and is missing a required automaticDataCollectionEnabled property expected by the auth module.

seems like we need to have the automaticDataCollectionEnabled property on our react-native-specific type, and our react-native-specific FirebaseApp tap should otherwise extend firebase/app-types FirebaseApp definition. We do want to return that as you might need the native utils stuff

But then the auth definition should be able to accept it if it's a sub-type with just something extra? or our auth stuff could accept both types, so that we worked drop-in for people that switched from firebase-js-sdk to react-native-firebase ?

If you change our types to do that (with some quick dummy implementation of automaticDataCollectionEnabled for proof-of-concept) does it work? Seems like it will based on the workaround you're using now

@github-actions github-actions bot removed the Stale label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention tools: typings TypeScript / Flow type: bug New bug report
Projects
None yet
Development

No branches or pull requests

2 participants