-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Closed
Copy link
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
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
// @strictNullChecks: true
declare function isFoo(): boolean;
declare function isBar(): 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 π
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug