You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create orval.config.js with output.client set to axios
run orval
What happens?
Orval generates the following broken code: ts playground
What were you expecting to happen?
Seemingly, the <Data = unknown> part cannot be parsed by typescript. Everything works perfectly fine if you remove the = unknown Though.
After searching for a while, It looks like there is really no way for having default value for generic object literal methods.
Not only the notation we use, but neither of { method: <Data = unknown>() => {} } nor { method: function<Data = unknown>() {} } works.
Solution
Multiple solutions comes to mind, but before anything, I'm failing to understand why the axios generator, unlike the others, generates the getExampleService function in the first place? Maybe it's a legacy thing we can fix while we are upgrading to v5? The problem wouldn't exist if the output was like the react-query one, only without the hooks.
But otherwise, doing the following can solve the issue: ts playground
I'm still only somewhat familiar with the codebase, So I don't know how exactly we can split the definition and the export. But I believe the return value can easily be generated just by putting all of the function names together, separated with commas.
What versions are you using?
**Package Version:**v5.1.3
The text was updated successfully, but these errors were encountered:
Wow! Nice catch I didn't saw the issue because I don't know why but when you have all options optional for the first function then typescript is happy 😭
What are the steps to reproduce this issue?
output.client
set to axiosWhat happens?
Orval generates the following broken code:
ts playground
What were you expecting to happen?
Seemingly, the
<Data = unknown>
part cannot be parsed by typescript. Everything works perfectly fine if you remove the= unknown
Though.After searching for a while, It looks like there is really no way for having default value for generic object literal methods.
Not only the notation we use, but neither of
{ method: <Data = unknown>() => {} }
nor{ method: function<Data = unknown>() {} }
works.Solution
Multiple solutions comes to mind, but before anything, I'm failing to understand why the axios generator, unlike the others, generates the
getExampleService
function in the first place? Maybe it's a legacy thing we can fix while we are upgrading to v5? The problem wouldn't exist if the output was like the react-query one, only without the hooks.But otherwise, doing the following can solve the issue:
ts playground
I'm still only somewhat familiar with the codebase, So I don't know how exactly we can split the definition and the export. But I believe the return value can easily be generated just by putting all of the function names together, separated with commas.
What versions are you using?
**Package Version:**v5.1.3
The text was updated successfully, but these errors were encountered: