openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Default export of the module has or is using private name 'ClientConfig'.

Open alainfonhof opened this issue 1 year ago • 8 comments

Description

When following the documentation I get a type error with the following code block:

import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
  input: 'path/to/openapi.json',
  output: 'src/client',
});

Default export of the module has or is using private name 'ClientConfig'.

It seems that only the type UserConfig is exported, however because type UserConfig = ClientConfig; the type ClientConfig is expected and this is a private interface.

OpenAPI specification (optional)

No response

Configuration

No response

System information (optional)

tsconfig

"compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "strict": true,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2020", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": "."
    }

typescript: 5.3.3

alainfonhof avatar Jun 07 '24 07:06 alainfonhof

Which package versions is this @alainfonhof?

mrlubos avatar Jun 09 '24 12:06 mrlubos

0.46.3

alainfonhof avatar Jun 09 '24 13:06 alainfonhof

@alainfonhof Are you able to create a StackBlitz example with reproducible project?

mrlubos avatar Jul 01 '24 14:07 mrlubos

In this https://stackblitz.com/edit/hey-api-example go to the file tsconfig.node.json and remove the line "include": ["vite.config.ts"]. Now in openapi-ts.config.ts, there is the error.

mauriciabad avatar Jul 07 '24 09:07 mauriciabad

~It seems related to the composite option, since if I remove it the error goes away.~ Well, no, because then the tsconfig.json gives an error

mauriciabad avatar Jul 07 '24 10:07 mauriciabad

Removing "references": [{ "path": "./tsconfig.node.json" }] from the tsconfig.json and also removing tsconfig.node.json fixed it for me.

mauriciabad avatar Jul 07 '24 10:07 mauriciabad

Removing composite: true from tsconfig.json fixed this issue for me as well. It seems like this might represent a different issue of being incompatible with multiple tsconfig files?

ajlamarc avatar Jul 27 '24 21:07 ajlamarc

inside the index.d.ts file from the hey-api package removed the error for me. I guess it will come back when / if the package is updated, or the repo is shared with someone else. But it was a quick fix for now :)

export interface ClientConfig { ...

LasseMunk avatar Aug 01 '24 09:08 LasseMunk

Changing ClientConfig from an interface to a type worked for this case https://github.com/storybookjs/storybook/issues/12064#issuecomment-1488872947 (so the type isn't exposed), but now it give the following errors

Default export of the module has or is using private name 'PluginTanStackReactQuery'.ts(4082)
Default export of the module has or is using private name 'PluginTanStackSolidQuery'.ts(4082)
Default export of the module has or is using private name 'PluginTanStackSvelteQuery'.ts(4082)
Default export of the module has or is using private name 'PluginTanStackVueQuery'.ts(4082)

So maybe it not related to openapi-ts?

Edit: environment is downloaded code from StackBlitz npm linked to local hey-api/open-api repo

jacobinu avatar Aug 22 '24 13:08 jacobinu

Ya it looks like a TypeScript issue https://github.com/Microsoft/TypeScript/issues/23280#issuecomment-379859847

Edit: That is the cause of the bug is UserConfig type aliases the interface ClientConfig https://github.com/hey-api/openapi-ts/blob/7e84960713160fc942c6e5a109e7d9687fb9dafc/packages/openapi-ts/src/types/config.ts#L237 This seems to be an unresolved issue

jacobinu avatar Aug 22 '24 15:08 jacobinu