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

fix: fix typing on core middy handler #630

Merged
merged 5 commits into from
Mar 26, 2021
Merged

fix: fix typing on core middy handler #630

merged 5 commits into from
Mar 26, 2021

Conversation

markcarroll
Copy link
Contributor

What does this implement/fix? Explain your changes.

With current Typescript definition it is not possible to locally execute the handler function, either from a local file to debug, or from unit tests, without getting a Typescript error:

This expression is not callable.
  Type 'MiddyfiedHandler<APIGatewayProxyEvent, APIGatewayProxyResult, Error>' has no call signatures.

I believe the issue is that the Typescript definition of the MiddyfiedHandler does not extend the Lambda Handler so is not a callable function.

Fix is to add LambdaHandler to the MiddyfiedHandler interface definition.

Does this close any currently open issues?

closes #628

Any relevant logs, error output, etc?

Any other comments?

Looking for someone else to validate this fix. Since it is only typing, it does not affect core functionality.

Where has this been tested?

Node.js Versions: v14.15.5

Middy Versions: 2.0.0.beta.0

AWS SDK Versions: v2/v3

Todo list

[ ] Feature/Fix fully implemented
[ ] Added tests
[ ] Updated relevant documentation
[ ] Updated relevant examples

@markcarroll markcarroll changed the base branch from master to release/2.x March 19, 2021 22:26
Change the definition so Typescript recomends against callback, per the new v2 design.
Copy link
Member

@lmammino lmammino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting this!

Do you think there is any way we can add a test for this in our typing tests?

@markcarroll
Copy link
Contributor Author

The reason it broke for me in the first place was when I tried to execute the handler as a callable function. It should be as simple as trying to call it as Lambda runtime would. I don’t have a window to look at it right now, but I will take a look when I get a chance.

@lmammino lmammino merged commit 83f9a54 into middyjs:release/2.x Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Typescript issue with v2 Beta 1: This expression is not callable
2 participants