openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
535 stars 67 forks source link

No exported member named 'AxiosRequestConfig'. Did you mean 'RequestConfig'? #173

Closed robogeek closed 5 months ago

robogeek commented 7 months ago

I generated a .d.ts file from an OpenAPI specification. At the top of the generated file is this:

import type {
  OpenAPIClient,
  Parameters,
  UnknownParamsObject,
  OperationResponse,
  AxiosRequestConfig,
} from 'openapi-client-axios'; 

For the last imported thing, Visual Studio Code shows a red line under the identifier AxiosRequestConfig. Further, compiling this with TypeScript generates this error:

src/openadr-3.d.ts:6:3 - error TS2724: '"openapi-client-axios"' has no exported member named 'AxiosRequestConfig'. Did you mean 'RequestConfig'?

6   AxiosRequestConfig,
    ~~~~~~~~~~~~~~~~~~

The OpenAPI file is for the OpenADR v3 protocol. In case that makes a difference, I can supply a copy.

My setup is -- I have one directory (builder) with a package.json that has scripts for building code into another directory (package) that I'm intending to publish as an npm package.

In builder/package.json here is the relevant code:

{
  ...
  "config": {
    "openadryaml": "../oadr3.0.1.yaml"
  },
  "scripts": {
    "build:typegen": "npx openapi-client-axios-typegen ${npm_package_config_openadryaml} >../package/src/openadr-3.d.ts",
  }
 ...
  "devDependencies": {
    "openapi-client-axios-typegen": "^7.4.1",
    "openapicmd": "^2.0.1"
  },
  ...
}

In other words, I'm using the CLI tool in openapi-client-axios-typegen, and used it exactly as documented. I also tried the openapicmd typegen tool, as follows, and got exactly the same error.

npx openapicmd typegen ../oadr3.0.1.yaml >../package/src/openadr-3.d.ts

Grepping for this, I found AxiosRequestConfig mentioned a few times in the axios package, FWIW.

UPDATE: The above error message does not appear alone. Rethinking this, the other error, printed immediately before the above, which is:

node_modules/openapi-client-axios/index.d.ts:3:15 - error TS2498: Module '"/home/david/Projects/openadr/openadr-3-ts-types/package/node_modules/axios/index"' uses 'export =' and cannot be used with 'export *'.

3 export * from 'axios';
                ~~~~~~~
anttiviljami commented 5 months ago

Update openapicmd & openapi-client-axios-typegen to latest. 🙏