You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
Some algorithms are best naturally coded using an "infinite" loop of the style:
while(true){
...
if(someCondition){break;}
...
}
but the strict-boolean-expressions tslint rule does not like this, giving the message:
This type is not allowed in the 'while' condition because it is always truthy. Only booleans are allowed.
This message is sensible for "if" statements, and also for "while" statements such as while (x !== null) (where "x" is known to be non-null).
But I would argue that using a literal "true", as in while (true) should not be an error, and is an intentional programming construct, and the strict-boolean-expressions rule should not report it as an error.
Thank you
The text was updated successfully, but these errors were encountered:
I use for(;;) { ... } which eliminates the conditional.
EDIT: In fact, I learned this originally when I use ESLint because of their documentation. Probably a separate issue, but TSLint could benefit from examples in the documentation.
Some algorithms are best naturally coded using an "infinite" loop of the style:
but the
strict-boolean-expressions
tslint rule does not like this, giving the message:This message is sensible for "if" statements, and also for "while" statements such as
while (x !== null)
(where "x" is known to be non-null).But I would argue that using a literal "true", as in
while (true)
should not be an error, and is an intentional programming construct, and thestrict-boolean-expressions
rule should not report it as an error.Thank you
The text was updated successfully, but these errors were encountered: