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
if(!arr.length){thrownewError("no items in array");}
✅ Good Example
if(0===arr.length){thrownewError("no items in array");}
Rationale
It's more difficult to do proper checking of type-constrained conditions if 0 and "" are considered valid boolean expressions.
For example:
/** @type {Number|String} foo */if(!foo){// if we constrain the boolean expression then we can detect// that there's a conflict between the code and the type:// `foo` is not optional according to the type, but perhaps the user thinks it can be}
The text was updated successfully, but these errors were encountered:
This rule is taken from Go.
❌ Bad Example
✅ Good Example
Rationale
It's more difficult to do proper checking of type-constrained conditions if
0
and""
are considered valid boolean expressions.For example:
The text was updated successfully, but these errors were encountered: