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

"error TS6133: 'queryKey' is declared but its value is never read" from queries.ts and suspense.ts #112

Closed
Etsija opened this issue May 13, 2024 · 4 comments · Fixed by #116
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Etsija
Copy link

Etsija commented May 13, 2024

Describe the bug
Files queries/queries.ts and queries/suspense.ts generate TS errors from queryKey being declared but its value never read, resulting in error TS6133 when building a project with the API.

OpenAPI JSON causing the bug
api.json

Expected behavior
Either don't generate unused parameters, or auto-insert

// @ts-nocheck

to generated files which may declare unused variables.

  • OS: Ubuntu 22.04
  • Version 1.3.0
@sschuberth
Copy link

Does this report, just like mine, need to go to upstream https://github.com/hey-api/openapi-ts as well?

@Etsija
Copy link
Author

Etsija commented May 15, 2024

I'd like an answer to the question above, as we need a fix to this issue, and need to know whether we should create a ticket upstream.

@seriouslag seriouslag added bug Something isn't working help wanted Extra attention is needed labels May 15, 2024
@seriouslag
Copy link
Collaborator

seriouslag commented May 15, 2024

This is a bug.
queryKey should always be used.
The issue is that when there are no parameters for a request, then the queryKey is not used in the hook; this is incorrect.
We should be using the provided queryKey if it is provided.

A work-around until a fix is implemented is to add the // @ts-nocheck to the files or to add the following properties to your tsconfig

{
  ...
  "noUnusedParameters": false,
  "noUnusedLocals": false
  ...
}

@Etsija
Copy link
Author

Etsija commented May 15, 2024

Thanks for the reply, I will be following this issue to see when a proper fix is implemented so we can remove our workarounds for it.

Etsija added a commit to doubleopen-project/ort-server that referenced this issue May 16, 2024
There is a bug [1] in the codegen tool that causes it to generate unused
query keys for requests with no parameters. This commit renames the
unused query keys to start with an underscore '_' to pass the lint
checks for unused variables.

NOTE: This is not a lasting solution, as every regeneration of the query
client will revert these changes.

[1]: 7nohe/openapi-react-query-codegen#112

Signed-off-by: Jyrki Keisala <[email protected]>
github-merge-queue bot pushed a commit to eclipse-apoapsis/ort-server that referenced this issue May 16, 2024
There is a bug [1] in the codegen tool that causes it to generate unused
query keys for requests with no parameters. This commit renames the
unused query keys to start with an underscore '_' to pass the lint
checks for unused variables.

NOTE: This is not a lasting solution, as every regeneration of the query
client will revert these changes.

[1]: 7nohe/openapi-react-query-codegen#112

Signed-off-by: Jyrki Keisala <[email protected]>
mmurto added a commit to mmurto/openapi-react-query-codegen that referenced this issue May 16, 2024
The query key functions for queries that don't take in additional request
parameters don't allow for using additional query key input, but query
hooks always take in a query key parameter. This leads to the query key
parameter in hooks without additional input being unused variable, leading
to TypeScript erroring. Fix this by always taking query key parameter in
query key functions, and always using it in query hooks.

Fixes 7nohe#112.

Signed-off-by: Mikko Murto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants