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
// @strictNullChecks: truedeclarefunctionisFoo(): boolean;declarefunctionisBar(): boolean;if(isFoo){// uncalled function checks already work well here}if(isFoo&&isBar()){// uncalled function checks already work well here}if(isFoo&&isFoo()){// uncalled function checks should cover this case too}if(isFoo&&isBar()){isFoo;// uncalled function checks should cover this case too}
π Actual behavior
In the last two cases we didn't detect that the first occurrence of isFoo in the condition is uncalled.
π Expected behavior
When isFoo cannot possibly be a falsy value (i.e. undefined) we should highlight this as an error even if isFoo occurs again later on. This is a follow-up to a conversation in #42835 (comment).
I would be happy to enable this check, then we could run this against some user tests and decide whether there are too many false positives π
The text was updated successfully, but these errors were encountered:
@RyanCavanaugh I'm probably misunderstanding your example, but if isFoo cannot possible be undefined, isn't the condition in the example you gave above redundant?
It's intentional that the rule is not ironclad. This is because there are some places in the language where TS thinks something is always not-undefined, but it's not necessarily the case.
Bug Report
π Search Terms
uncalled function checks
,conjunction
,&&
π Version & Regression Information
This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
In the last two cases we didn't detect that the first occurrence of
isFoo
in the condition is uncalled.π Expected behavior
When
isFoo
cannot possibly be a falsy value (i.e.undefined
) we should highlight this as an error even ifisFoo
occurs again later on. This is a follow-up to a conversation in #42835 (comment).I would be happy to enable this check, then we could run this against some user tests and decide whether there are too many false positives π
The text was updated successfully, but these errors were encountered: