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

🏷️ ensures that handler return is properly typed #1244

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

canassa
Copy link
Contributor

@canassa canassa commented 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 #1228

- 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
@willfarrell willfarrell merged commit a823417 into middyjs:main Oct 16, 2024
6 of 10 checks passed
@willfarrell
Copy link
Member

Thanks for the PR!

@canassa
Copy link
Contributor Author

canassa commented Oct 16, 2024

@willfarrell Thanks! Do you know if this will be included in a release soon? or only after 6.X?

@willfarrell
Copy link
Member

It's in release 5.5.1 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Handler return is not type-checked.
2 participants