swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Define instance member properties in class 'HttpClient ' as instance member methods

Open SaschaGalley opened this issue 2 years ago • 1 comments

Instead of rewriting the templates, I want to be able to extend the underlying HttpClient class, e.g.:

class ApiWithErrorHandling extends Api<any> {

  async request<T = any, E = any>(params: FullRequestParams): Promise<HttpResponse<T, E>> {
    try {
      return super.request(params);
    } catch (e) {
      // do error handling (e.g. logout)
      throw e;
    }
  }

}

which results in the following error:

Class 'Api ' defines instance member property 'request', but extended class 'ApiWithErrorHandling' defines it as instance member function.

Is there any reason, why the HttpClient class is designed that way?

SaschaGalley avatar Jan 10 '22 10:01 SaschaGalley

Have the same issue.

megastels avatar Mar 25 '22 10:03 megastels