Skip to content

bug(types): firebase.reauthenticate isn't working with TypeScript #909

@alekseykarpenko

Description

@alekseykarpenko

Do you want to request a feature or report a bug?

Seems like a bug regarding the documentation

What is the current behavior?
Actually I can't use reauthenticate() as described in docs.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

There are two problems regarding reauthenticate:

  1. It isn't provided in the outgoing interface for TypeScript, I'm currently facing this:
    TS2339: Property 'reauthenticate' does not exist on type 'ExtendedFirebaseInstance & ExtendedAuthInstance & ExtendedStorageInstance'.
    2. Even when adding //@ts-ignore, my App is falling with error that seems shouldn't be related:
    Application verifier is required for phone authentication
    But i'm trying to reauthenticate with email and password. not the phone:

    UPD: Okay, I previously tried to use it in a wrong way, but still to make it work I need three different ts-ignores:
    // #1
    // @ts-ignore
    const credential = firebase.auth.EmailAuthProvider.credential(user?.email, password);
    // #2
    // @ts-ignore
    return firebase.reauthenticate({credential})
      .then(() => {})
      // #3
      // @ts-ignore
      .catch((e) => { console.log(e); })

#1 Is because of Property 'EmailAuthProvider' does not exist on type '() => FirebaseAuth'.
Removing #2 causes: Property 'reauthenticate' does not exist on type 'ExtendedFirebaseInstance & ExtendedAuthInstance & ExtendedStorageInstance'.
And #3 stands for classic: Parameter 'e' implicitly has an 'any' type. as I don't know what type of error should be here

What is the expected behavior?
I wan't to reauthenticate my user on security-sensitive actions using TypeScript and as described in docs:
https://react-redux-firebase.com/docs/auth.html#logincredentials-and-reauthenticatecredentials

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

"dependencies": {
    "react": "^16.13.1",
    "react-redux": "^7.2.0",
    "react-redux-firebase": "^3.3.0"
}

Activity

changed the title [-]firebase.reauthenticate isn't working[/-] [+]firebase.reauthenticate isn't working with TypeScript[/+] on Apr 11, 2020
ghost

ghost commented on May 22, 2020

@ghost

Having similar issue which is probably related :
Property 'GoogleAuthProvider' does not exist on type '() => FirebaseAuth'.

prescottprue

prescottprue commented on May 26, 2020

@prescottprue
Owner

Thanks for calling out - Right now we are just using () => AuthTypes.FirebaseAuth where AuthTypes comes from Firebase. I'll look into how they are doing the types for Auth since it should also include statics

prescottprue

prescottprue commented on May 31, 2020

@prescottprue
Owner

I actually appears that part of what they are doing matches what we are doing, but there is some other types in there that we will need to match.

Would love a PR if anyone gets a chance, been a bit busy lately

changed the title [-]firebase.reauthenticate isn't working with TypeScript[/-] [+]bug(types): firebase.reauthenticate isn't working with TypeScript[/+] on May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @prescottprue@alekseykarpenko

        Issue actions

          bug(types): firebase.reauthenticate isn't working with TypeScript · Issue #909 · prescottprue/react-redux-firebase