-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
[strict-boolean-expressions] False negative for generic parameters #3644
Comments
The rule sees the type By the default configuration of the rule, |
That's a big assumption especially because
|
I'd be happy if the rule were updated to do the following:
no need for an option or anything here, as I think this is just a logical improvement to the rule's logic. |
Repro
Expected Result
Both
if (foo.pop())
andif (bar.pop())
should produce warnings. Both are potentiallyundefined
and most likely not booleans.foo.pop()
has the return typeS | undefined
andbar
hasnumber | undefined
.Actual Result
if (foo.pop())
does not produce a warning despite almost certainly not being a boolean.I found that if the condition is a union with a type parameter (
S | anything
), thenstrict-boolean-expressions
won't report anything. This is a problem because that means that the rule cannot check all conditions inside generic functions.Additional Info
Versions
@typescript-eslint/eslint-plugin
4.28.4
@typescript-eslint/parser
4.23.0
TypeScript
4.2.4
ESLint
7.26.0
node
14.15.4
The text was updated successfully, but these errors were encountered: