title: Member 'success' in 'SingleEvent<_>' produces result of type 'SingleEvent<Element>'
body: <p>can someone explain what is the error here ?</p>
  
  <pre><code>Member 'success' in 'SingleEvent&lt;_&gt;' produces result of type 'SingleEvent&lt;Element&gt;', but context expects 'SingleEvent&lt;_&gt;'
  </code></pre>
  
  <p>I return a Single either error or success with a generic type
  if the result case is .success I want to pass JSON in the single event</p>
  
  <p><a href="https://i.stack.imgur.com/3h8kt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3h8kt.png" alt="enter image description here"></a></p>
  
  <p>this is the full code</p>
  
  <pre><code>import Foundation
  import RxSwift
  
  public class APIClient&lt;T: APIProtocol&gt; {
      var disposeBag: DisposeBag = DisposeBag()
  }
  
  extension APIClient {
      public func get&lt;U&gt;(apiService: T, key: String) -&gt; Single&lt;U&gt; {
          return Single.create { single in
  
              let task = TaskRequestManager.run(apiService, completion: { result in
                  DispatchQueue.main.async {
                      switch result {
  
                      case .error(let error):
                          single(.error(error))
                      case .success(let json):
  
                          guard let JSON = json[key] as? [String: Any] else {
                              single(.error(ApiError.jsonParsingFailure))
                              return
                          }
                          single(.success(JSON))
                      }
                  }
  
              })
              task.resume()
              return Disposables.create {
                  task.cancel()
              }
      }
          }
  }
  </code></pre>