Skip to content

AppleError and other enums are not available on runtime #366

Description

@petetnt

Hi,

I am trying to use the AppleError enum in a runtime check, which looks something like this:

import {
  appleAuth,
  AppleError
} from '@invertase/react-native-apple-authentication';

...

export function isNativeFirebaseError(
  error: any
): error is ReactNativeFirebase.NativeFirebaseError {
  return error && error.code && error.message;
}


try {
  // do stuff
} catch (err) {
  if (isNativeFirebaseError(err) && err.code === AppleError.FAILED) {
    // do stuff
  }
}

The issue is that while the typechecking passes, AppleError enum is not available at runtime as it's declared in

export declare enum AppleError {

console.log(AppleError) // undefined

However, the code is correctly assigned in the error:

try {
  // do stuff
} catch (err) {
  if (isNativeFirebaseError(err) && err.code === "1004") {
    // does not throw, it's ok!
  }
}

This also affects all the other declared enums on that file too. I think the easiest fix would be removing the declare keyword from the typedef or marking them as const instead.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions