openapi-ts
openapi-ts copied to clipboard
ESLint no-invalid-void-type error in services.gen.ts
Description
Actual
In the services.gen.ts
there are void is only valid as a return type or generic type argument.eslint[@typescript-eslint/no-invalid-void-type](https://typescript-eslint.io/rules/no-invalid-void-type)
errors appearing.
Expected
The eslint page suggests to use undefined
instead.
That would mean that these appearances would change as follows:
export const postAuthResetPassword = <ThrowOnError extends boolean = false>(
options: Options<PostAuthResetPasswordData, ThrowOnError>,
) => {
- return (options.client ?? client).post<void, unknown, ThrowOnError>({
+ return (options.client ?? client).post<undefined, unknown, ThrowOnError>({
...options,
url: "/auth/reset_password",
});
};
Reproducible example or configuration
https://stackblitz.com/edit/hey-api-client-fetch-example-nppfy7?file=src%2Fclient%2Fservices.gen.ts
Then run npm run lint
. Quite some issues will appear, but some will be like:
/home/projects/hey-api-client-fetch-example/src/client/services.gen.ts
…
153:57 error void is only valid as a return type or generic type argument
OpenAPI specification (optional)
Any OpenAPI endpoint that does return nothing basically.
System information (optional)
Only thing important to mention here, is a more strict eslint config:
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
These were added/edited to the base stackblitz example. It is the recommended production setup by the vite react-ts template (see README)