Closed mat813 closed 3 years ago
@mat813, there are no guaranties that openapi-client-axios
will use the same version of the axios
that you used to provide AxiosRequestConfig
from the root package. So, that error is expected and will show you all incompatibilities if you will use wrong config (during type-checking stage).
So, at first one, I do not see any reason to forcing that type because ts will resolve it automatically as type from 'openapi-client-axios'. But anyway if you or your linter prefer no-any
everywhere you should get that type for a client type version that really will be used, as example:
api.init().then((client) => {
type UseFullfiedParameters = Parameters<typeof client.interceptors.request.use>[0]
type OAAxiosRequestConfig = Parameters<UseFullfiedParameters>[0]
client.interceptors.request.use(
(config: OAAxiosRequestConfig ): OAAxiosRequestConfig => { ... }
)
})
At the second one, openapi-client-axios
was recently updated to use the latest axios
, could help, but not in perfectly way in my mind.
Hi @mat813, @npdev453 axios is now used as a peerDependency, which should solve the issue (or at least make the behaviour clearer).
Feel free to contact me if there are still issues regarding this!
I am converting some code base to typescript, and I scratched my head for something like half an hour with this error:
All that because VSCode added the import from axios and not from openapi-client-axios. Then I noticed that difference:
I don't really understand why there is such a difference, but, well, it would be nice if the validateStatus signature was compatible.