-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
!constant
in boolean expression not reported (function not called error)
#45667
Comments
Duplicate of #44840 |
I'm not convince this is a duplicate of #44840 as it doesn't reference the existing checks. Would it be possible to explain why |
The fact that |
So this is definitely confusing, especially because the error messages are similar; but my understanding is
I think we're trying to be "too smart" in the second example though. I would expect |
Detecting |
Bug Report
It is a common source of bugs that developers fail to call functions in boolean expressions. This, among other reasons, the compiler checks for constant boolean expressions. However, there seems to be a hole in the existing checks. TSC currently allows "!fn" where "fn" and "(!fn) == true" are not allowed. It would be beneficial to check this kind of expression as well.
🔎 Search Terms
function "condition always true"
function constant boolean expression
🕗 Version & Regression Information
unknown, presumably since the beginning of time, at least TS 3.3, related improvement in TS 3.7
⏯ Playground Link
Playground link with relevant code
https://www.typescriptlang.org/play?ts=3.7.5&q=247#code/GYVwdgxgLglg9mABMMAKAlIg3ogTgUyhFyQHIBDAIwlIG5EBfAWAChWZhFUVMtmWOXAIQ9s-QdyQBeKYii4Q+XuM6pUIsJhlyFSsa1ZA
💻 Code
🙁 Actual behavior
No warning
🙂 Expected behavior
"This condition will always ..." warning
The text was updated successfully, but these errors were encountered: