We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
There should be a tsconfig option to enable strict type-checking of loop condition predicates
tsconfig
while, loop, for, bool, boolean
My suggestion meets these guidelines:
A tsconfig bool option named typeCheckedLoops (or something else) that throws an error when any condition isn't a boolean
typeCheckedLoops
boolean
I was surprised that TS allowed the following (even with very strict config):
while ("true"); while (!""); while ([]); for (;{};);
None of those are bools (except !""), yet they don't trigger any errors
!""
This becomes a problem when the condition is a variable, or an expression composed of multiple vars.
The text was updated successfully, but these errors were encountered:
Essentially a duplicate of #38826.
Sorry, something went wrong.
Thank you for the info. I'll close this
No branches or pull requests
Suggestion
There should be a
tsconfig
option to enable strict type-checking of loop condition predicates🔍 Search Terms
while, loop, for, bool, boolean
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
A
tsconfig
bool option namedtypeCheckedLoops
(or something else) that throws an error when any condition isn't aboolean
📃 Motivating Example
I was surprised that TS allowed the following (even with very strict config):
None of those are bools (except
!""
), yet they don't trigger any errors💻 Use Cases
This becomes a problem when the condition is a variable, or an expression composed of multiple vars.
The text was updated successfully, but these errors were encountered: