Skip to content

TypeScript errors when using methodNameBuilder (private type 'IROperationObject' / 'Operation') #2813

@ArtemAstakhov

Description

@ArtemAstakhov

Description

After updating to the latest version, TypeScript shows errors when using methodNameBuilder.

Default export of the module has or is using private name 'IROperationObject'.ts
Default export of the module has or is using private name 'Operation'.

Reproducible example or configuration

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

export default defineConfig({
  input: 'http://localhost:5000/api/docs-json',
  output: './lib',
  parser: {
    transforms: {
      enums: false,
    },
  },
  plugins: [
    {
      name: '@hey-api/client-fetch',
      throwOnError: true,
      baseUrl: false,
      bundle: true,
    },
    {
      name: '@hey-api/transformers',
      dates: true,
    },
    {
      name: '@hey-api/sdk',
      transformer: true,
      asClass: true,
      classNameBuilder: (name: string) => `${name}Service`,
      methodNameBuilder: (operation) => {
        if ('operationId' in operation && !isNil(operation.operationId)) {
          const parts = operation.operationId!.split('_');

          if (parts.length === 1) {
            return parts[0];
          }

          return parts[1];
        }

        if ('id' in operation && !isNil(operation.id)) {
          return operation.id!;
        }

        return operation.path ?? '';
      },
    },
    {
      name: '@hey-api/typescript',
      enums: 'typescript',
    },
  ],
});

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

Labels

bug 🔥Something isn't workingprioritized 🚚This issue has been prioritized and will be worked on soon

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions