-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Handler return is not type-checked. #1228
Labels
Comments
This seems to be a regression with Middy 5. Middy 4 is able to correctly validate the type:
|
A PR is welcome for this. |
On it 🙏 Will keep you posted. |
jerizm
added a commit
to jerizm/middy
that referenced
this issue
Sep 18, 2024
jerizm
added a commit
to jerizm/middy
that referenced
this issue
Sep 18, 2024
jerizm
added a commit
to jerizm/middy
that referenced
this issue
Sep 18, 2024
jerizm
added a commit
to jerizm/middy
that referenced
this issue
Sep 18, 2024
canassa
pushed a commit
to canassa/middy
that referenced
this issue
Oct 15, 2024
- This change addresses an issue where the return type of handlers was not being correctly enforced by the TypeScript compiler. As far as I could tell, the issue is caused by the `infer` keyword not working with generic types. - Added `TResult` as a type parameter to `MiddlewareHandler` to explicitly specify the handler's return type. - Modified the `middy` function signature to pass `TResult` to `MiddlewareHandler`. - By explicitly specifying `TResult`, we ensure that the compiler can correctly enforce the handler's return type. closes middyjs#1228
canassa
pushed a commit
to canassa/middy
that referenced
this issue
Oct 15, 2024
- This change addresses an issue where the return type of handlers was not being correctly enforced by the TypeScript compiler. As far as I could tell, the issue is caused by the `infer` keyword not working with generic types. - Added `TResult` as a type parameter to `MiddlewareHandler` to explicitly specify the handler's return type. - Modified the `middy` function signature to pass `TResult` to `MiddlewareHandler`. - By explicitly specifying `TResult`, we ensure that the compiler can correctly enforce the handler's return type. closes middyjs#1228
canassa
pushed a commit
to canassa/middy
that referenced
this issue
Oct 18, 2024
- This change addresses an issue where the return type of handlers was not being correctly enforced by the TypeScript compiler. As far as I could tell, the issue is caused by the `infer` keyword not working with generic types. - Added `TResult` as a type parameter to `MiddlewareHandler` to explicitly specify the handler's return type. - Modified the `middy` function signature to pass `TResult` to `MiddlewareHandler`. - By explicitly specifying `TResult`, we ensure that the compiler can correctly enforce the handler's return type. closes middyjs#1228
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using TypeScript, the return of a handler is not being validated by the type checker.
To Reproduce
Add this file
Expected behaviour
The type checker should have throw an error since
123
does not match theAPIGatewayProxyResult
.Note: I know that this can be workaround by manually adding the return type to the handler function, but that's more error prone.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: