fetch-client icon indicating copy to clipboard operation
fetch-client copied to clipboard

invalid type definition for RetryInterceptor

Open reinholdk opened this issue 6 years ago • 3 comments

there seems to be an error in the type definition of RetryInterceptor

aurelia-fetch-client 1.8.0 typescript 3.2.4

https://github.com/aurelia/fetch-client/blob/fa53ec779f2e0937129010e952c57568842bd46b/dist/aurelia-fetch-client.d.ts#L310`

error TS2416: Property 'response' in type 'RetryInterceptor' is not assignable to the same property in base type 'Interceptor'.
  Type '(response: Response, request: Request) => Response' is not assignable to type '(response: Response, request?: Request | undefined) => Response | Promise<Response>'.
    Types of parameters 'request' and 'request' are incompatible.
      Type 'Request | undefined' is not assignable to type 'Request'.
        Type 'undefined' is not assignable to type 'Request'.

reinholdk avatar Jan 28 '19 07:01 reinholdk

I had the same issue so, I just edited the definition file myself. This isn't a lasting change but it will atleast let you build your project for now.

	export declare class RetryInterceptor implements Interceptor {
		retryConfig: RetryConfiguration;
		constructor(retryConfig?: RetryConfiguration);
		request(request: Request): Request;
		response(response: Response, request?: Request): Response;
		responseError(error: Response, request?: Request, httpClient?: HttpClient): Promise<Response>;
	}

evanlarsen avatar Jan 31 '19 20:01 evanlarsen

I did the something similar as a quick fix.

export declare class RetryInterceptor implements Interceptor {
    retryConfig: RetryConfiguration;
    constructor(retryConfig?: RetryConfiguration);
    request(request: Request): Request;
    response(response: Response, request?: Request): Response | Promise<Response>;
    responseError(error: Response, request?: Request, httpClient?: HttpClient): Response | Promise<Response>;
}

I would be happy to make the fix on the definition file and create a PR, but I'm not sure if it is being automatically generated. @EisenbergEffect If it is not auto-generated, please let me know and I will submit a PR.

tareqimbasher avatar Jan 31 '19 20:01 tareqimbasher

We recently switch this repo over to using TS as its source language. So, the d.ts file is now generated directly from TS. I think a PR directly to the src folder to correct it there would be the way to go. Thanks for volunteering @tareqimbasher !

EisenbergEffect avatar Feb 01 '19 00:02 EisenbergEffect