Skip to content

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

Closed
@garyking

Description

@garyking

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions