-
Notifications
You must be signed in to change notification settings - Fork 930
Upgrading to 10.3.0 broke TypeScript detecting getReactNativePersistence
function for Expo RN
#7584
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
Comments
I have been banging my head against the wall for this exact same problem! Anyone have any solutions? |
Hi @seanblonien, thanks for bring this to our attention. I was able to replicate the behavior you mentioned. I’ll notify our team about these issues so that they can provide more context and investigate what might be causing this. |
That's odd, I tested this specifically in a new Expo project ( See this comment in a closed issue: TLDR: Here's one way this can happen, if you've customized your Metro config. Link is here: #7115 (comment) and I'll re-paste it for convenience
Edit: One last thing, if this is the case, you should have been having this problem ever since upgrading from any version of 9 to 10.0.0, that's when the "firebase/auth/react-native" explicit path was removed and replaced with the automatic resolution. |
@hsubox76 According to the Expo Firebase Docs when upgrading to a version |
So the problem occurs when applying metro config customizations in a way that somehow accidentally sets Also if anyone's seeing this error and targeting web with RN (not iOS/Android), let me know. |
|
I also just tested out the suggested Metro config in the Expo Firebase docs and it seems to work fine, the |
Sorry, I didn't realize this was specifically a VSCode editor issue. Am I correct that this isn't affecting any builds? So I have narrowed down the problem. There's a specific TypeScript definitions file for the React Native auth bundle, and if you look at the package.json for
Unfortunately it looks like Metro (by default at least) doesn't use the
along with "browser", "main", etc, but unfortunately when using this format, you can't specify a custom typings file to go along with each JS bundle, and (as far as I know) you're stuck with providing one universal type definitions file which is expected to match all the bundles (this is actually rewritten to "auth-public.d.ts" at release time btw): firebase-js-sdk/packages/auth/package.json Line 143 in b2f6084
So basically that typings definition bundle will work for the majority of auth bundles (for web, Node), but won't work for RN as it's missing Edit: Again, let me know if this affects any builds or anything beyond the editor and warnings. |
@hsubox76 Yeah, I think that's accurate. Personally speaking, I haven't had any issues running/building with the version of Firebase (10.0.3), but was having to suppress the typescript error in VSCode which I'd prefer to not have to do. |
I am new so I apologize. Does this mean that Persistence won't work with Expo then? The main reason I ran into this problem was because it doesn't remember that you logged in after you exit the app then return again. That is quite frustrating. |
It works. I've followed the code example in the firebase release notes. I've opened a issue/question with the Expo folks as their docs seems to be a little contradictory for firebase 10. From what I read, they make it sound like it's no longer necessary, but then if you remove it you end up with the warning and no persistence. |
This is just an editor error and I don't think it will affect the actual functionality of the code. The code in the warning should compile and work fine despite what the editor says. (But let me know if it doesn't.) The first workaround I found so far for the VSCode error is to create a
This forces VSCode to look at the There's a very long and controversial issue thread in the TypeScript repo about TypeScript supporting typings from the Hopefully that helps for now and I will see if it's possible on our end to make auth-public.d.ts even more generic so it covers the RN use case. |
That is on us and not on the Expo folks as we did make persistence "just work" out of the box as of 10.0.0 but had to roll it back as of 10.3.0 as it was negatively impacting non-React-Native users. |
@hsubox76 thank you for this quick fix, error goes away and the expo app bundles successfully without error! 🎉 Conclusion: the code is totally functional as described in the firebase documentation, and this really is just a VSCode/TypeScript issue (exactly what @hsubox76 predicted) I did have custom metro config, but I did not have to make any additional changes related to the resolver - I just have Expo's suggested resolver code documented here (mentioned previously) -- so do that if you have not already Lastly, thank you @hsubox76 for seeing if you can update |
It seems to be working fine for me now. I didn't realize that the fix that came up in the terminal does actually fix it. I was thrown off by the TypeScript errors. I am new so I have been always making sure the TS is correct, so when I see errors it scares me, haha! All good. I just did what you said and added the path to the tsconfig, and bingo. Thanks all. |
I'm actually having a hard time pinpointing where the TS problem is. Looking through Typescript issues, it looks like Typescript ought to support the In any case, if there was some kind of typescript config that would support it following the react-native exports path correctly (in a less hacky way than |
I've added the following to my tsconfig.json file to resolve the initial problem:
Now I'm getting the following error from Expo Router (V2):
|
How are you importing it? import { initializeAuth, getReactNativePersistence } from "firebase/auth"; And then you also need: import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage'; I am very new though, so don't take my word for it until someone else gives their input. |
My mistake. I imported getReactNativePersistence instead of browserSessionPersistence. |
Thank you so much for this fix. |
1- Navigate to @firebase/auth in node_modules: 2- Edit package.json: 3- Modify the typings Field: 4- json
|
try this> import { initializeApp } from 'firebase/app'; export const firebaseConfig = { export const app = initializeApp(firebaseConfig); export const auth = initializeAuth(app, { if (!firebase.apps.length) { // Firestore instance |
Hey @seanblonien. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Not sure if there's much more information to give but the issue title is a bit misleading. It's a problem if you use Typescript in a React Native app - not just VSCode. i.e. I see it in IntelliJ but also if I check types with just Typescript cli The provided workaround of specifying the type location in tsconfig works for me but not sure if this is the official solution? |
Hey @seanblonien. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
getReactNativePersistence
function for Expo RNgetReactNativePersistence
function for Expo RN
Since there haven't been any recent updates here, I am going to close this issue. @seanblonien if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
The described solution fixed the getReactNativePersistence for Native, but getting the same error now on web version ((0 , _auth.getReactNativePersistence) is not a function). Is there a fix if you want the app to work in browser and native? Currently fixed it like this, not sure if there is a better way?
|
See this issue, it may help: #7615 (comment) I made some suggestions and the user tried a different solution, see if any of those work for you. I think your solution is pretty decent, but as I'm not a RN expert, I don't know if the "official" RN way of splitting it into different files (as linked in that comment) is more robust or anything. |
For me on my Expo React Native app, hsubox76 comment fixed the typescript issue, but then the auth wasn't working on the web version, throwing an error for the |
what does your tsconfig look like? changing the path to support the rn export breaks the web export. so now it's showing browserSessionPersistence doesn't exist smh |
@Martijncvv just a quick follow up to see if you can share what your |
Nothing special:
I suppress the typescript import error/ warning with a basic @ts-ignore. Hope it will be fixed it soon :) |
I still faced this issue When I created a new Expo standalone app, I no longer experienced the issue so it must be related to the fact that the project I'm currently working on is an Expo app inside an Nx monorepo. This workaround worked for me:
In general though, this issue should not be closed! I have a standalone expo with firebase that has a clear repro: |
Operating System
iOS 16.4
Browser Version
Chrome latest
Firebase SDK Version
10.3.0
Firebase SDK Product:
Auth
Describe your project's tooling
Expo tooling React Native app with Firebase JS SDK
(Expo 49.0.0)
(VSCode 1.81.1)
Describe the problem
I was following 10.3.0's new error message:
introduced by #7570, and yet somehow it was missed that the

getReactNativePersistence
function is no longer exported from thefirebase/auth
entry point as of 10.0.0 according to VSCode (does not seem to pick up the native entry point if that function is exported):how do I get my editor to detect the new native entry point?
is this new entry point pattern compatible with managed
expo
projects, or only barereact-native
projects?(running the numbers quickly,
expo
is just over 1/3 of thereact-native
community according to NPM downloads)#7138 seems to blatantly remove those exported functions without re-exporting them, which seems like they literally are just not exposed and virtually "deleted" from the library. or the native detection just isn't working at all for me, so direction on how to get that working would be helpful
Steps and code to reproduce issue
auth
objectThe text was updated successfully, but these errors were encountered: