Home > database >  It works sometimes, but some throws error: Generic parameter 'T' could not be inferred - S
It works sometimes, but some throws error: Generic parameter 'T' could not be inferred - S

Time:12-26

Until now I had no problems, which is the weird part. Swift never complained about this code. A user got an error signing up and me debugging put a print statement and maybe because of the introspection of the code now swift caught the error and is saying:

Generic parameter 'T' could not be inferred

I thought this is how you handle continuation, what's wrong in my code? The funny thing is that it works sometimes, others it throws the error above :/

The error is in line: try await withCheckedThrowingContinuation

Here's the full code:

// Signup
final func signUp(username: String, email: String, password: String) async throws -> (message: String, didItSucceed: Bool) {
    print("➡️ About to sign up user")
    
    try await withCheckedThrowingContinuation { continuation in
        let userAttributes = [AuthUserAttribute(.email, value: email)]
        let options = AuthSignUpRequest.Options(userAttributes: userAttributes)
        
        _ = Amplify.Auth.signUp(
            username: username,
            password: password,
            options: options
        ) { result in
            switch result {
                case .success(let signUpResult):
                    print("✅ Signup confirmed. Next-> needs email verification from \(email)")
                    
                    switch signUpResult.nextStep {
                        case .done:
                            print("✅ Finished sign up!")
                        case .confirmUser(_, _):
                            DispatchQueue.main.async {
                                // Confirm the Auth State to confirm code passing in the username to confirm
                                self.authState = .login
                            }
                            continuation.resume(returning: ("Check your Email            
  • Related