Generic parameter 'T' could not be inferred - Swift 5.5

Viewed 2096

I'm trying to get the user sign in and I'm getting the following error:

Generic parameter 'T' could not be inferred

This is the code:

// Gets User signed-in
func getUser() async throws -> AuthUser {
    do {
        try await withUnsafeThrowingContinuation { continuation in
            if let user = Amplify.Auth.getCurrentUser() {
                continuation.resume(returning: user )
            }
        }
    } catch(let error) {
        print(error)
    }
}

Why is that?

1 Answers

Actually my call was not good at all in the first place, this is how it should be done:

// Gets User signed-in
func getUser() async throws -> AuthUser {
    return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<AuthUser, Error>) in
        if let user = Amplify.Auth.getCurrentUser() {
            continuation.resume(returning: user)
        } else {
            signOut()
        }
    }
}

For more info go here

Related