Skip to content

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

Open
@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"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions