Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Lintrule "invalid-void" should permit Promise<void> #4834

Closed
Akuukis opened this issue Aug 22, 2019 · 1 comment
Closed

Lintrule "invalid-void" should permit Promise<void> #4834

Akuukis opened this issue Aug 22, 2019 · 1 comment

Comments

@Akuukis
Copy link

Akuukis commented Aug 22, 2019

Bug Report

  • TSLint version: 5.19.0
  • TypeScript version: 3.5.3
  • Running TSLint via: CLI

I generally support invalid-void lint rule

Restrict invalid usage of void type. For example, as property type or in type enumerations. I believe the void type should be used as return type only and be alone (without any kind of intersection types - see examples below).

But I suggest to permit Promise<void> return type also. IMO it's wrong to force to change all of them to Promise<undefined>, that only escalates to TS error: A function whose declared type is neither 'void' nor 'any' must return a value.ts(2355)

TypeScript code being linted

async function myAsyncFn(): Promise<void> {
    return Promise.resolve()
}

Actual behavior

Fails lint rule invalid-void #4732

Expected behavior

Passes

@adidahiya
Copy link
Contributor

duplicate of #4828

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants