Skip to content
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

Export User Flow type #704

Closed
fdnhkj opened this issue Dec 20, 2017 · 2 comments
Closed

Export User Flow type #704

fdnhkj opened this issue Dec 20, 2017 · 2 comments
Assignees
Labels
tools: typings TypeScript / Flow

Comments

@fdnhkj
Copy link
Contributor

fdnhkj commented Dec 20, 2017

Issue

I created a function to loginOrRegister from facebook login.
To add a Flow return type to its method signature, I would need the User type to be exported.
I am not sure how it has to be done (export User class from dist/index.js ?, export an interface?, export a type?) but I would be happy to contribute if someone could give details.

See Promise<User> in return type of function below.

export default function loginOrRegister(): Promise<User> {
  const permissions = ['public_profile', 'email'];

  return LoginManager.logInWithReadPermissions(permissions)
    .then(result => {
      if (result.isCancelled) {
        return Promise.reject(new Error('The user cancelled the request'));
      }
      return AccessToken.getCurrentAccessToken();
    })
    .then(data => {
      if (!data) {
        return Promise.reject(
          new Error("facebook-auth: couldn't get current access token")
        );
      }
      const credential = firebase.auth.FacebookAuthProvider.credential(
        data.accessToken
      );
      return firebase.auth().signInWithCredential(credential);
    })
    .catch(error => {
      const { code, message } = error;
      logging.recordError({
        domain: 'Facebook Login error',
        message,
        code
      });
      return Promise.reject(error);
    });
}

Environment

  1. Application Target Platform: Both
  2. Development Operating System: macOS Sierra
  3. React Native version: ^0.49.5
  4. RNFirebase Version: ^3.1.1
  5. Firebase Module: auth
@chrisbianca
Copy link
Contributor

@fdnhkj Thanks, we're aware of this and haven't quite figured out the best approach yet either! We're open to suggestions...

@chrisbianca chrisbianca added the tools: typings TypeScript / Flow label Dec 21, 2017
@chrisbianca chrisbianca self-assigned this Jan 3, 2018
@chrisbianca
Copy link
Contributor

@fdnhkj This will be fixed in the next release. You'll be able to do:

import type { User } from 'react-native-firebase';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools: typings TypeScript / Flow
Projects
None yet
Development

No branches or pull requests

2 participants