hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client
https://heyapi.vercel.app
Other
1.07k stars 89 forks source link

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

Closed ygpark80 closed 4 days ago

ygpark80 commented 1 week 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 1 week ago

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

mrlubos commented 1 week ago

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

image

ygpark80 commented 1 week ago

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

mrlubos commented 1 week ago

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

batleforc commented 5 days ago

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

batleforc commented 5 days 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 5 days ago

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

Client, QuerySerializerOptions and RequestOptionsBase.

ygpark80 commented 4 days ago

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

mrlubos commented 4 days 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