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

Update AWS TypeScript handler template #5309

Merged
merged 1 commit into from Sep 18, 2018
Merged

Conversation

uneco
Copy link
Contributor

@uneco uneco commented Sep 18, 2018

What did you implement:

aws-nodejs-typescript handler template of new notation similar to:
https://github.com/serverless/serverless/blob/master/lib/plugins/create/templates/aws-nodejs/handler.js

How did you implement it:

Just like the js version

How can we verify it:

sls create --template aws-nodejs-typescript

Todos:

  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO


export const hello: Handler = (event: APIGatewayEvent, context: Context, cb: Callback) => {
const response = {
export const hello: APIGatewayProxyHandler = async (event, context) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the types from the function parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the current template, it was necessary to explicitly indicate the type of the arguments -- that's because the used insufficient type Handler.
now, by storing function to the constant of type APIGatewayProxyHandler, the types of event and context are implicitly inferred. Please see the attached image.

screenshot

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@franciscocpg franciscocpg left a comment

Choose a reason for hiding this comment

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

LGTM

@horike37 horike37 added this to the 1.33.0 milestone Sep 18, 2018
Copy link
Member

@horike37 horike37 left a comment

Choose a reason for hiding this comment

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

@uneco
It works! LGTM 👍
Thank you for your contribution. This will be shipped in upcoming release 😄

@horike37 horike37 merged commit 5b9faca into serverless:master Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants