Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

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 force-pushed the function-handler-void branch from 4f88d47 to 91aa17b Compare October 4, 2022 12:54
@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.

@danez danez requested a review from eduardoboucas October 4, 2022 12:57
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
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