Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interceptor return types are incorrect. #158

Open
plwalters opened this issue Dec 4, 2016 · 11 comments
Open

Interceptor return types are incorrect. #158

plwalters opened this issue Dec 4, 2016 · 11 comments

Comments

@plwalters
Copy link
Contributor

The return types should match the fetch spec, in particular the requestError and responseErrors should have valid return types (they do not appear to from what I can tell)

@plwalters
Copy link
Contributor Author

I'm looking in to this now to see if the description is correct or the docs are incorrect, either way I will tidy this one up.

@plwalters
Copy link
Contributor Author

Ok sorry looks like requestError expects for a return type of the RequestMessage but I'm not sure where that should be derived from, could by my mistake. responseErrors looks good.

@AMCN41R
Copy link

AMCN41R commented Feb 10, 2017

I'm experiencing an issue related to the return types in a typescript project.

The docs, under Basic Http Interceptors, show that you can 'throw error' for requestError and responseError, but this does not compile due to the type definitions expecting the return type to be RequestMessage | Promise<RequestMessage> and HttpResponseMessage | Promise<HttpResponseMessage> respectively.

For example, the following interceptor...

export class MyInterceptor implements Interceptor {
    responseError(error: HttpResponseMessage) {
        throw error;
    }
}

results in...

'Class 'MyInterceptor' incorrectly implements interface 'Interceptor'.
  Types of property 'responseError' are incompatible.
    Type '(error: HttpResponseMessage) => void' is not assignable to type '(error: HttpResponseMessage) => HttpResponseMessage | Promise<HttpResponseMessage>'.
      Type 'void' is not assignable to type 'HttpResponseMessage | Promise<HttpResponseMessage>'.'

I can fix this by changing throw error to return Promise.reject<HttpResponseMessage>(error)

However, doing the same for requestError would look like...

export class MyInterceptor implements Interceptor {
    requestError(error: Error) {
        return Promise.reject<RequestMessage>(error);
    }
}

Is that right?

@loku02
Copy link

loku02 commented May 12, 2017

Any movement regarding this topic?

@djensen47
Copy link

All of the documentation for the fetch client needs to be refreshed. The API docs are incomplete and the example usage here is also possibly incorrect: http://aurelia.io/docs/plugins/http-services#aurelia-fetch-client

@Alexander-Taran
Copy link

Would you like to provide a pull request for it @djensen47 ?

@djensen47
Copy link

I need to figure out how the project documentation works. I probably won't be able to get to that for a few days/weeks.

@Alexander-Taran
Copy link

I could point you in right direction. (-:
https://github.com/aurelia/fetch-client/blob/master/doc/article/en-US/http-services.md

@djensen47
Copy link

Thanks! How do the API docs work? I think that has the bigger issue of no documentation. Or at the very least, I would start with the API docs, then make sure that the guide is correct (or if I have to eat my hat 😉 🍽 🎩 ).

@Alexander-Taran
Copy link

Api docs are automated in collecting annotations. Mostly.

@Alexander-Taran
Copy link

@bigopon maybe can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants