openapi-react-query-codegen
openapi-react-query-codegen copied to clipboard
"error TS6133: 'queryKey' is declared but its value is never read" from queries.ts and suspense.ts
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
Does this report, just like mine, need to go to upstream https://github.com/hey-api/openapi-ts as well?
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.
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
...
}
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.