invertase / react-native-apple-authentication

A React Native library providing support for Apple Authentication on iOS and Android.
Other
1.36k stars 215 forks source link

Missing initializer in const declaration - AppleButton #315

Closed hajajmaor closed 8 months ago

hajajmaor commented 1 year ago

Expo project. Xcode was configured, and the sign in with apple capability was added.

Error:

iOS Bundling failed 811ms
error: SyntaxError: /Users/user/projects/project_something/node_modules/@invertase/react-native-apple-authentication/lib/index.d.ts: Missing initializer in const declaration. (121:30)

  119 |   Type: typeof AppleButtonType;
  120 |   Style: typeof AppleButtonStyle;
> 121 | } & React.FC<AppleButtonProps>;
      |                               ^
  122 |
  123 |
  124 | /** iOS */

package.json - changed private values:

{
  "name": "",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "android:noCache": "expo run:android --no-build-cache",
    "ios": "expo run:ios",
    "ios:noCache": "expo run:ios --no-build-cache",
    "web": "expo start --web",
    "prebuild": "expo prebuild",
    "prebuild:podInstall": "expo prebuild;pod-install",
    "eject": "expo eject",
},
  "dependencies": {
    "@invertase/react-native-apple-authentication": "^2.2.2",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/datetimepicker": "6.5.2",
    "@react-native-community/hooks": "^2.8.1",
    "@react-native-firebase/app": "^16.4.6",
    "@react-native-firebase/auth": "^16.4.6",
    "@react-native-google-signin/google-signin": "^8.2.1",
    "@react-navigation/native": "^6.0.11",
    "@react-navigation/native-stack": "^6.7.0",
    "axios": "^0.27.2",
    "expo": "~47.0.8",
    "expo-dev-client": "~2.0.1",
    "expo-image-picker": "~14.0.2",
    "expo-splash-screen": "~0.17.5",
    "expo-status-bar": "~1.4.2",
    "expo-system-ui": "~2.0.1",
    "expo-updates": "~0.15.6",
    "formik": "^2.2.9",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-native": "0.70.5",
    "react-native-date-picker": "^4.2.3",
    "react-native-fbsdk-next": "^11.1.0",
    "react-native-modal-datetime-picker": "^14.0.0",
    "react-native-popup-menu": "^0.15.12",
    "react-native-safe-area-context": "4.4.1",
    "react-native-screens": "~3.18.0",
    "react-native-select-dropdown": "^2.0.4",
    "react-native-web": "~0.18.7",
    "react-social-icons": "^5.15.0"
  },
  "devDependencies": {
    "@babel/core": "^7.19.3",
    "@types/react": "~18.0.24",
    "@types/react-native": "~0.70.6",
    "eslint-plugin-react": "^7.31.11",
    "pod-install": "^0.1.38",
    "prop-types": "^15.8.1",
    "typescript": "^4.6.3"
  },
  "private": true
}

Apple component:

import appleAuth from "@invertase/react-native-apple-authentication";
import auth from "@react-native-firebase/auth";
import {AppleButton} from '@invertase/react-native-apple-authentication';

const AppleSignInBtn = () => {

    async function onAppleButtonPress() {
        // performs login request
        const appleAuthRequestResponse = await appleAuth.performRequest({
            requestedOperation: appleAuth.Operation.LOGIN,
            requestedScopes: [appleAuth.Scope.EMAIL],
        });

        // Ensure Apple returned a user identityToken
        if (!appleAuthRequestResponse.identityToken) {
            throw new Error('Apple Sign-In failed - no identify token returned');
        }

        // Create a Firebase credential from the response
        const {identityToken, nonce} = appleAuthRequestResponse;
        const appleCredential = auth.AppleAuthProvider.credential(identityToken, nonce);
        console.log(appleCredential);
        console.log(appleAuthRequestResponse.email);
        // Sign the user in with the credential
        return auth().signInWithCredential(appleCredential);
    }
    return (
        <AppleButton
            // testID="AppleSignInBtn"
            // style={{width: 200, height: 50}}
            // cornerRadius={5}
            // key="apple"
            buttonStyle={AppleButton.Style.WHITE}
            buttonType={AppleButton.Type.SIGN_IN}
            onPress={onAppleButtonPress}
        />
    );
}
export default AppleSignInBtn;

I created a new clean project using the same component and the same bundle id, works fine!!

mikehardy commented 1 year ago

I created a new clean project using the same component and the same bundle id, works fine!!

Great! So this module works? What exactly is the actionable item here? Are you going to propose a PR or ? I'm confused.

hajajmaor commented 1 year ago

The same component works fine in a new project with the same configuration. I have this issue on my project with all of the deps I copied to the issue, and I can't figure out why it happens:

iOS Bundling failed 811ms
error: SyntaxError: /Users/user/projects/project_something/node_modules/@invertase/react-native-apple-authentication/lib/index.d.ts: Missing initializer in const declaration. (121:30)

  119 |   Type: typeof AppleButtonType;
  120 |   Style: typeof AppleButtonStyle;
> 121 | } & React.FC<AppleButtonProps>;
      |                               ^
  122 |
  123 |
  124 | /** iOS */