Skip to content

TS stableTypeOrdering flag causes generated client-fetch params.gen.ts to fail typecheck #3862

@khludenevav

Description

@khludenevav

Description

When using @hey-api/openapi-ts with the @hey-api/client-fetch plugin, the generated file src/client/core/params.gen.ts fails TypeScript typechecking when stableTypeOrdering is enabled.

The failing generated line is:

params[field.map] = value;

In my repro, this becomes:

src/client/core/params.gen.ts(145,13): error TS2322: Type 'unknown' is not assignable to type 'Record<string, unknown>'.

The same generated output typechecks successfully when stableTypeOrdering is disabled.

This makes migration to TS 7.0 impossible

Reproducible example or configuration

Minimal repro repo:

Local repro commands:

pnpm install
pnpm run generate
pnpm run typecheck:without-stable
pnpm run typecheck

Observed behavior:

  • pnpm run typecheck:without-stable passes
  • pnpm run typecheck fails in generated src/client/core/params.gen.ts

Relevant config:

export default {
  input: './openapi.json',
  output: 'src/client',
  plugins: ['@hey-api/typescript', '@hey-api/sdk', '@hey-api/client-fetch'],
};
{
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "skipLibCheck": true,
    "stableTypeOrdering": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "target": "ES2022",
    "lib": ["ES2022", "DOM", "DOM.Iterable"]
  },
  "include": ["src/**/*.ts"]
}

OpenAPI specification (optional)

The repro repo includes a minimal openapi.json that is enough to make openapi-ts emit the failing params.gen.ts helper.

System information (optional)

  • @hey-api/openapi-ts: 0.97.1
  • typescript: 6.0.3
  • pnpm: 10.17.1
  • OS: macOS

Additional context

This looks like a generator typing issue in the shared client-fetch helper template rather than an application-specific problem, because the failure is isolated to generated code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions