hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.43k stars 106 forks source link

Build Error in @hey-api/client-fetch v0.3.2: Unnamed ‘Client’ and ‘RequestOptionsBase’ Issues #1078

Closed ygpark80 closed 2 months ago

ygpark80 commented 2 months ago

Description

For @hey-api/client-fetch version 0.3.2, I get the following error when building:

% npm run build

> tsc -p tsconfig.cjs.json

src/services.gen.ts:6:14 - error TS4023: Exported variable 'client' has or is using name 'Client' from external module "<path>/node_modules/@hey-api/client-fetch/dist/index" but cannot be named.

6 export const client = createClient(createConfig());
               ~~~~~~

src/services.gen.ts:6:14 - error TS4023: Exported variable 'client' has or is using name 'RequestOptionsBase' from external module "<path>/node_modules/@hey-api/client-fetch/dist/index" but cannot be named.

6 export const client = createClient(createConfig());
               ~~~~~~

Found 2 errors in the same file, starting at: src/services.gen.ts:6

This error does not occur in version 0.3.1.

Reproducible example or configuration

https://stackblitz.com/edit/stackblitz-starters-kx7wy2

OpenAPI specification (optional)

3.0.1

System information (optional)

No response

stackblitz[bot] commented 2 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

mrlubos commented 2 months ago

Hey @ygpark80, this is what I'm seeing. How do I get to the error you reported?

image

ygpark80 commented 2 months ago

Run npm run generate to generate the sources, and then run npm run build.

mrlubos commented 2 months ago

Thanks, I see. Let me look into this, I just switched the type generator step and broke this in the process

batleforc commented 2 months ago

Same issue with @hey-api/client-axios in 0.2.5

batleforc commented 2 months ago

And editing client-axios/dist/index.d.ts by adding an export line 72 before the interface seems to fix

// Previous code
export interface Client {
 // Remaining of the client
gugahoi commented 2 months ago

I also has similar issues. I needed to export the following interfaces for code to compile:

Client, QuerySerializerOptions and RequestOptionsBase.

ygpark80 commented 2 months ago

Wow, thanks a lot! I’ve confirmed that it’s working.

mrlubos commented 2 months ago

No worries, that's my fault! I should add tests with different configurations as it doesn't always throw depending on your tsconfig.json