-
Notifications
You must be signed in to change notification settings - Fork 12.8k
NonNullable should consider the void type #36703
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
Comments
|
@MartinJohns If there is some other definition then IMO, this is a bug in the documentation |
I'm not sure where you get this from. The documentation you linked states:
Absence of having a type means it can be any value, not just This FAQ section is relevant: https://github.com/microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void #35236 and #35850 have a lot of discussions regarding this behavior as well and mentions why something like With a small adjustment of your code the issue should become more clear:
The type of the else-branch is
By using the appropriate type: |
the problem is that using |
I guess this is controlled by |
TypeScript Version: 3.7.5
Search Terms: NonNullable void
Code
Expected behavior:
should work fine, because
!= null
is alsonot void
Actual behavior:
getting
Type 'void' is not assignable to type 'true'.
workaround
I'm using
which works fine
The text was updated successfully, but these errors were encountered: