title: I'm having difficulty defining the type of setUser() for firebase user in react typescript
body: <p>I have a state for users where after the registration user details will be set on the user state. But I'm having difficulty defining the type of setUser. I have created a custom hook for firebase authentication it is working fine on the custom hook page but when I import the user into another page the output shows like this <code>async (email, password, history) =&gt; { setIsLoading(true); await (0,firebase_auth__WEB........</code></p>
  <p>My mistake is, I set an empty <em><code>firebaseUserFunction</code></em> object, but I don't know what type would be. Check the below code</p>
  <pre><code>type firebaseUserFunction = {}
  
  
  export const UseFirebase = (
      context?: any
  ): [RegisterUserFunction, SignInUserFunction, SignOutFunction, firebaseUserFunction] =&gt; {
    const [user, setUser] = useState({}) 
  ...
  </code></pre>
  <p>Firebase will return after registration, like the below object.</p>
  <pre><code>{providerId: 'firebase', proactiveRefresh: ProactiveRefresh, reloadUserInfo: {…}, reloadListener: null, uid: '8duKNA3jOSQouUFDYjZmNPuyHNE3', …}
  accessToken: &quot;eyJhbGciOiJSUzI1NiIsImtpZCI6ImYyNGYz&quot;
  auth: AuthImpl {app: FirebaseAppImpl, config: {…}, currentUser: UserImpl, emulatorConfig: null, operations: Promise, …}
  displayName: &quot;ff fff&quot;
  email: &quot;admin@admin.com&quot;
  emailVerified: false
  isAnonymous: false
  </code></pre>
  <p>This useEffect will set User details after successful register or sign in.</p>
  <pre><code>  // OBSERVE A USER
      useEffect(() =&gt; {
          const unsubscribed = onAuthStateChanged(auth, (user) =&gt; {
              setIsLoading(true)
              if (user) {
                  setUser(user)
              } else {
                  setUser({})
              }
              setIsLoading(false)
              return () =&gt; unsubscribed;
  
          });
  
      }, [auth])
  </code></pre>
  <p><strong>The main problem is I am not getting the above object after importing the user state to another page.</strong></p>
  <p>Full code</p>
  <pre><code>// type for the RegisterUserFunction
  type RegisterUserFunction = (
      email: string,
      password: string,
      name: string,
  ) =&gt; Promise&lt;void&gt;;
  
  type SignInUserFunction = (
      email: string,
      password: string,
      history: any
  ) =&gt; Promise&lt;void&gt;;
  
  type SignOutFunction = {}
  
  type firebaseUserFunction = {}
  
  
  export const UseFirebase = (
      context?: any
  ): [RegisterUserFunction, SignInUserFunction, SignOutFunction, firebaseUserFunction] =&gt; {
      const [user, setUser] = useState({})
      const [error, setError] = useState('')
      const [admin, setAdmin] = useState(false)
      const [isLoading, setIsLoading] = useState(true)
      const auth = getAuth()
  
      // REGISTER WITH EMAIL AND PASSWORD
      const RegisterUser: RegisterUserFunction = async (
          email: string,
          password: string,
          name: string,
      ) =&gt; {
          setIsLoading(true)
          const userCredential = await createUserWithEmailAndPassword(auth, email, password)
          const newUser = {
              email,
              displayName: name
          };
  
          setUser(newUser);
          setError('')
  
          // Pass userCredential.user instead of auth.currentUser
          updateProfile(userCredential.user, {
              displayName: name
          }).then(() =&gt; { }).catch((error) =&gt; { });
          // history.replace('/');
      };
  
      // OBSERVE A USER
      useEffect(() =&gt; {
          const unsubscribed = onAuthStateChanged(auth, (user) =&gt; {
              setIsLoading(true)
              if (user) {
                  setUser(user)
              } else {
                  setUser({})
              }
              setIsLoading(false)
              return () =&gt; unsubscribed;
  
          });
  
      }, [auth])
      console.log('firebase', user);
  </code></pre>
  <p>Can anyone please help me, how can I solve it?</p>