Skip to content

[no-invalid-void-type] Should accept void | Promise<void> #1956

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

Closed
garyking opened this issue Apr 29, 2020 · 2 comments · Fixed by #1960
Closed

[no-invalid-void-type] Should accept void | Promise<void> #1956

garyking opened this issue Apr 29, 2020 · 2 comments · Fixed by #1960
Labels
enhancement New feature or request good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@garyking
Copy link
Contributor

I've got a function that accepts a function, that should return void. But it can sometimes be async, so it would return Promise<void>. The rule should accept a union of both.

So that the following is acceptable:

async function foo(bar: () => void | Promise<void>) {
  await bar();
}

The other option would be to, of course, only accept Promise<void>, but then I'd have to put async on even funcs that don't use await, and then I'd get lint errors because of that. I think the solution proposed here is easier, and should still be in line with the spirit of the rule.

@garyking garyking added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 29, 2020
@bradzacher bradzacher added enhancement New feature or request good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Apr 30, 2020
@bradzacher
Copy link
Member

seems reasonable - happy to accept a PR

@Raynos
Copy link

Raynos commented May 2, 2020

👍 ; ran into this issue today as well.

@bradzacher bradzacher added the has pr there is a PR raised to close this label May 2, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants