Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] typescript-fetch produces types with unused imports and arguments #20776

Open
2 of 6 tasks
eTallang-politiet opened this issue Mar 3, 2025 · 0 comments
Open
2 of 6 tasks

Comments

@eTallang-politiet
Copy link

eTallang-politiet commented Mar 3, 2025

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When we create types through the openapi-generator-cli, the generated TypeScript files contains some unused imports and arguments. Among these are import { mapValues } from '../runtime'; at the top of each file, and ignoreDiscriminator as an unused argument to each ...FromJSONTyped function.

These unused imports and arguments become an issue when we try to build our app and do type checking through tsc. Since these files are imported throughout our app to use the types, there is no way to exclude them from type checking externally.

Is there any way to prevent the type generator to generate files with unused imports and arguments, or could the generated files perhaps be annotated with // @ts-nocheck at the top of the file to exclude them from the tsc type checker?

openapi-generator version

2.17.0

Suggest a fix

The issue can be fixed if the generated output-files could be annotated with // @ts-nocheck at the top of each file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant