openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

When using Axios client the TypeScript generated types are incorrect with latest version of [email protected]

Open callmeberzerker opened this issue 3 years ago • 5 comments

Here is an example of the error message from the generated request.ts core file.

TS2322: Type 'AxiosResponse<unknown, any>' is not assignable to type 'AxiosResponse<T, any>'.
  Type 'unknown' is not assignable to type 'T'.
    'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
        return axiosError.response;

callmeberzerker avatar Jun 15 '22 07:06 callmeberzerker

I'm getting this too. Have you found a workaround?

jtc42 avatar Aug 15 '22 13:08 jtc42

@jtc42 I am not sure what fixed it - but I don't have the problem anymore. I think some dependency was off - but I can't recall.

callmeberzerker avatar Aug 16 '22 20:08 callmeberzerker

Ah ok, thanks for the tip!

jtc42 avatar Aug 24 '22 14:08 jtc42

If you found a solution write it down here for the next passer-by! Don't make my mistake. 😄

callmeberzerker avatar Aug 25 '22 10:08 callmeberzerker

If you found a solution write it down here for the next passer-by! Don't make my mistake. 😄

Truth be told we just switched to OpenAPI Generator. It's definitely clunkier than this repo but for our specific requirements it was a neater fit anyway.

jtc42 avatar Aug 25 '22 11:08 jtc42