Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

always specify return-type of api-calls #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MaZderMind
Copy link

currently, the response-type of the data-attribute of the response of an api-call has to be deduced by following the lambda to the parametrized request function and evaluating it return type. This confuses the JetBrains (ie. IntelliJ / WebStorm) language server and it can't deduce the return-type of an await or then-statement correctly. I'm not sure if the VSCode language server handles this better, but I would expect it to have similar problems.

By specifying the return-type explicitly, the language-servers can easily deduce the type of the response.

this enhances compatibility with language-servers, especially it allowa the JetBrains language server to correctly resolve the return-type
switch(config.httpClientType) {
case HTTP_CLIENT.AXIOS: {
return `Promise<AxiosResponse<${type}>>`
}
default: {
return `Promise<HttpResponse<${type}, ${errorType}>`
return `Promise<HttpResponse<${type}, ${errorType}>>`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no Idea how that worked in the past 😬

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

Successfully merging this pull request may close these issues.

1 participant