Skip to content

Can't import error TypeScript types for AuthErrorCode #4551

@jmagaram

Description

@jmagaram

[REQUIRED] Describe your environment

  • Operating System version: irrelevant Windows 10 latest
  • Browser version: irrelevant latest Edge/Chrome
  • Firebase SDK version: 8.2.9
  • Firebase Product: AUTH

[REQUIRED] Describe the problem

I'm trying to code some auth stuff in a TypeScript Angular project, like this.auth.signOut(); and this.auth.signInAnonymously();. I'm trying to catch the errors but there seems to be no way to strongly type them using TypeScript. So I need to do code like this but can't use TypeScript intellisense to browse the available errors and get no warning if the error code string I use does not exist.

async signInAnonymously() {
  try {
    const credential = await this.auth.signInAnonymously();
  } catch (e) {
    if (e.code === 'auth/network-request-failed') {
      // do stuff
    }

The error codes are documented in...

https://firebase.google.com/docs/reference/node/firebase.auth.Error

I can see that every error is defined in this file in an enum AuthErrorCode
https://github.com/firebase/firebase-js-sdk/blob/20a88da5d935fdb8c1ff38e358c84e1939145abb/packages-exp/auth-exp/src/core/errors.ts

..But this is not publicly/easily accessible in my code. The package these are in says "This package is not intended for direct usage".

PLEASE make all the error codes accessible through a package I can import. Ideally I could get at the Enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions