@@ -10,6 +10,7 @@ export type WrappedComponentProps = {
1010  signInWithFacebook : ( )  =>  void ; 
1111  signInWithGithub : ( )  =>  void ; 
1212  signInWithTwitter : ( )  =>  void ; 
13+   signInWithPhoneNumber :  ( phoneNumber : string ,  applicationVerifier : firebase . auth . ApplicationVerifier )  =>  Promise < any > ; 
1314  signInAnonymously : ( )  =>  void ; 
1415  signOut : ( )  =>  void ; 
1516  setError : ( error : any )  =>  void ; 
@@ -68,16 +69,17 @@ const withFirebaseAuth = ({
6869
6970      setError  =  ( error : any )  =>  this . setState ( {  error } ) ; 
7071
71-       tryTo  =   async   ( operation : ( )  =>  any )   = >{ 
72+       async   tryTo  < T >   ( operation : ( )  =>  Promise < T > ) :  Promise < T >  { 
7273        try  { 
73-           return  await   operation ( ) ; 
74+           return  operation ( ) ; 
7475        }  catch ( error )  { 
7576          this . setError ( error . message ) ; 
77+           return  error ; 
7678        } 
7779      } ; 
7880
79-       tryToSignInWithProvider  =  ( provider : PossibleProviders )  => 
80-         this . tryTo ( ( )  =>  { 
81+       tryToSignInWithProvider  =  ( provider : PossibleProviders ) :  Promise < firebase . auth . UserCredential >  => 
82+         this . tryTo < firebase . auth . UserCredential > ( ( )  =>  { 
8183          const  providerInstance  =  providers [ provider ] ; 
8284
8385          if  ( ! providerInstance )  { 
@@ -88,10 +90,10 @@ const withFirebaseAuth = ({
8890        } ) ; 
8991
9092      signOut  =  ( )  => 
91-         this . tryTo ( ( )  =>  firebaseAppAuth . signOut ( ) ) ; 
93+         this . tryTo < void > ( ( )  =>  firebaseAppAuth . signOut ( ) ) ; 
9294
9395      signInAnonymously  =  ( )  => 
94-         this . tryTo ( ( )  =>  firebaseAppAuth . signInAnonymously ( ) ) ; 
96+         this . tryTo < firebase . auth . UserCredential > ( ( )  =>  firebaseAppAuth . signInAnonymously ( ) ) ; 
9597
9698      signInWithGithub  =  ( )  => 
9799        this . tryToSignInWithProvider ( 'githubProvider' ) ; 
@@ -106,10 +108,13 @@ const withFirebaseAuth = ({
106108        this . tryToSignInWithProvider ( 'facebookProvider' ) ; 
107109
108110      signInWithEmailAndPassword  =  ( email : string ,  password : string )  => 
109-         this . tryTo ( ( )  =>  firebaseAppAuth . signInWithEmailAndPassword ( email ,  password ) ) ; 
111+         this . tryTo < firebase . auth . UserCredential > ( ( )  =>  firebaseAppAuth . signInWithEmailAndPassword ( email ,  password ) ) ; 
112+ 
113+       signInWithPhoneNumber  =  ( phoneNumber : string ,  applicationVerifier : firebase . auth . ApplicationVerifier )  => 
114+         this . tryTo < firebase . auth . ConfirmationResult > ( ( )  =>  firebaseAppAuth . signInWithPhoneNumber ( phoneNumber ,  applicationVerifier ) ) 
110115
111116      createUserWithEmailAndPassword  =  ( email : string ,  password : string )  => 
112-         this . tryTo ( ( )  =>  firebaseAppAuth . createUserWithEmailAndPassword ( email ,  password ) ) ; 
117+         this . tryTo < firebase . auth . UserCredential > ( ( )  =>  firebaseAppAuth . createUserWithEmailAndPassword ( email ,  password ) ) ; 
113118
114119      sharedHandlers  =  { 
115120        signInWithEmailAndPassword : this . signInWithEmailAndPassword , 
@@ -118,6 +123,7 @@ const withFirebaseAuth = ({
118123        signInWithTwitter : this . signInWithTwitter , 
119124        signInWithGoogle : this . signInWithGoogle , 
120125        signInWithFacebook : this . signInWithFacebook , 
126+         signInWithPhoneNumber : this . signInWithPhoneNumber , 
121127        setError : this . setError , 
122128        signInAnonymously : this . signInAnonymously , 
123129        signOut : this . signOut , 
0 commit comments