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

feat: add new BackgroundHandler type #364

Merged
merged 1 commit into from
Oct 5, 2022
Merged

feat: add new BackgroundHandler type #364

merged 1 commit into from
Oct 5, 2022

Conversation

danez
Copy link
Contributor

@danez danez commented Oct 4, 2022

Fixes netlify/docs#2328

Promise<void> is a valid return type for a function.

example:

const handler: Handler = async () => {
  return;
}

I also added tsd to test for the types.

@danez danez requested review from eduardoboucas and a team October 4, 2022 10:36
@danez danez added the type: bug code to address defects in shipped code label Oct 4, 2022
Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

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

This is an interesting one. It's true that returning void is acceptable for a background function, but not for a synchronous function.

I wonder if in the same way we have a Handler type, we should have a specific type for background functions?

@danez danez changed the title fix: allow Promise<void> to be returned from function handler feat: add new BackgroundHandler type Oct 4, 2022
@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Oct 4, 2022
@danez
Copy link
Contributor Author

danez commented Oct 4, 2022

So I changed it to include one more type for background functions.

Copy link
Member

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

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

Nice!

@danez danez merged commit b2d112b into main Oct 5, 2022
@danez danez deleted the function-handler-void branch October 5, 2022 06:43
danez pushed a commit that referenced this pull request Oct 5, 2022
🤖 I have created a release *beep* *boop*
---


## [1.3.0](v1.2.0...v1.3.0)
(2022-10-05)


### Features

* add new BackgroundHandler type
([#364](#364))
([b2d112b](b2d112b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants