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] allowSafe should allow safe literal string/number types #1785
Comments
merging into #1515 |
@bradzacher this isn't really part of reworking the options, but rather an oversight (bug) in the current implementation of an existing option. Are we saying that (potential) bugs in the existing options will not be fixed in favor of the rework options issue? |
Adding this in will be a relatively non-trivial amount of work, so I figured that considering there's already a PR for the rework open, that it was better to consolidate discussion and work there. However, if you're happy to work on a PR to add this check into the current rule, then happy to accept a PR. |
Reopening this as we'll defer this work until after #1515 is closed. |
this was fixed long time ago in #3236 |
I think this is a different issue. #3115->#3236 were about With
...but, while this isn't quite the same, I think this is more of a feature request than a bug. The rule's intent is to stop you from directly checking values with types like Since there has been almost no noise on this issue since it was posted 2.5 years ago, we've reworked the rule since this issue, similar situations are fixed, and the workaround is pretty trivial (add Thanks all! |
Repro
Expected Result
The
if
checks of the literal types should not have any error, as they are safe checks.Actual Result
The if checks are flagged as if they weren't safe (as if they were not the literal types, but instead were
string
ornumber
, which would not be safe).Versions
@typescript-eslint/eslint-plugin
2.17.0
@typescript-eslint/parser
2.17.0
TypeScript
3.7.5
ESLint
6.8.0
node
13.7.0
npm
6.13.6
The text was updated successfully, but these errors were encountered: