-
-
Notifications
You must be signed in to change notification settings - Fork 384
fix: specify event type explicitly #1295
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.
8000By 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
Conversation
3e0d230
to
190bd4d
Compare
- fixes the issue of the event type not being correctly inferred by the Typescript compiler since the `infer` keyword does not properly work with generic types - change adopts the same solution as for [middyjs#1228: Handler return is not type-checked.](middyjs#1228) , that is adding `TEvent` as a type parameter to the `Middlewarehandler` allows to explicitly indicate the handler's event type closes[middyjs#1293](middyjs#1293) Signed-off-by: contexD <39738016+contexD@users.noreply.github.com>
190bd4d
to
c6a3eca
Compare
Thanks for the PR! |
thanks for the PR! Nonetheless, this is a breaking change as per SemVer. I know it is too late cause it has been released and all, but some migration notes can be provided to make lib users easier. For us we had to change from:
to
No how the use of "as" dissappeared/casting. the issue appeared on usages of above middy:
transpiling issue:
most likely this is the detonator: https://github.com/middyjs/middy/pull/1295/files#r2092966279 |
TResult = any, | ||
TEvent = any | ||
> = | ||
THandler extends LambdaHandler<TEvent, TResult> // always true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anchor
A PR to further improve types is always welcome. |
oh yeah, definitely. Just adding this comment to help others and asking you guys to help further by flagging this as a hidden breaking change in the release notes in order to help others even further. |
fixes the issue of the event type not being correctly inferred by the Typescript compiler since the
infer
keyword does not properly work with generic typeschange adopts the same solution as for middyjs#1228: Handler return is not type-checked. , that is adding
TEvent
as a type parameter to theMiddlewareHandler
allows to explicitly indicate the handler's event typecloses #1293