My code doesn't work, although it was made using this tutorial (link to exact file with AuthContext). This snippet in particular is a part of Auth Context. The only difference is that I code in typescript instead of JS. Tell me whether you need anything else to help me solve my issue.
useEffect(() => {
        const user = supabase.auth.getUser().user;
        setCurrentUser(user)
        const auth = supabase.auth.onAuthStateChange((event, session) => {
            if (event === 'SIGNED_IN') {
                setCurrentUser(session.user)
            }
            if (event === 'SIGNED_OUT') {
                setCurrentUser(null)
            }
        })
        return () => auth.data.unsubscribe()
    }, [])
Errors:
ERROR in src/contexts/AuthContext.tsx:76:46
TS2339: Property 'user' does not exist on type 'Promise<UserResponse>'.
    74 |
    75 |     useEffect(() => {
  > 76 |         const user = supabase.auth.getUser().user;
       |                                              ^^^^
    77 |         setCurrentUser(user)
    78 |
    79 |         const auth = supabase.auth.onAuthStateChange((event, session) => {
ERROR in src/contexts/AuthContext.tsx:81:32
TS2531: Object is possibly 'null'.
    79 |         const auth = supabase.auth.onAuthStateChange((event, session) => {
    80 |             if (event === 'SIGNED_IN') {
  > 81 |                 setCurrentUser(session.user)
       |                                ^^^^^^^
    82 |             }
    83 |
    84 |             if (event === 'SIGNED_OUT') {
ERROR in src/contexts/AuthContext.tsx:81:32
TS2345: Argument of type 'User' is not assignable to parameter of type 'SetStateAction<undefined>'.
  Type 'User' provides no match for the signature '(prevState: undefined): undefined'.
    79 |         const auth = supabase.auth.onAuthStateChange((event, session) => {
    80 |             if (event === 'SIGNED_IN') {
  > 81 |                 setCurrentUser(session.user)
       |                                ^^^^^^^^^^^^
    82 |             }
    83 |
    84 |             if (event === 'SIGNED_OUT') {
ERROR in src/contexts/AuthContext.tsx:85:32
TS2345: Argument of type 'null' is not assignable to parameter of type 'SetStateAction<undefined>'.
    83 |
    84 |             if (event === 'SIGNED_OUT') {
  > 85 |                 setCurrentUser(null)
       |                                ^^^^
    86 |             }
    87 |         })
    88 |
ERROR in src/contexts/AuthContext.tsx:89:32
TS2339: Property 'unsubscribe' does not exist on type '{ subscription: Subscription; }'.
    87 |         })
    88 |
  > 89 |         return () => auth.data.unsubscribe()
       |                                ^^^^^^^^^^^
    90 |
    91 |     }, [])
    92 |
Thanks in advance for help
 
     
     
    