TsoaResponse
Generic Should Specify BodyType
as return value, not any
#1665
Labels
TsoaResponse
Generic Should Specify BodyType
as return value, not any
#1665
Sorting
I'm submitting a ...
I confirm that I
Current And Expected Behavior
Following the getting started guide on error handling via this page: https://tsoa-community.github.io/docs/error-handling.html
The typing for TsoaReponse should not return
any
as it fails this eslint rule:Unsafe return of a value of type `any`.eslint[@typescript-eslint/no-unsafe-return](https://typescript-eslint.io/rules/no-unsafe-return)
This is the code I'm testing with the errored line commented:
To prevent the error I have to coerce the
notFoundReponse
call like below:return notFoundResponse( 404, { message: "User not found" } ) as NotFoundResponseBody
Possible Solution
Change the current typing to return
BodyType
instead ofany
- like this:export type TsoaResponse<T extends HttpStatusCodeLiteral, BodyType, HeaderType extends IsValidHeader<HeaderType> = {}> = (status: T, data: BodyType, headers?: HeaderType) => BodyType;
Context (Environment)
Version of the library:
The text was updated successfully, but these errors were encountered: