Skip to content

Uncalled function checks don't work with negationΒ #43096

Open
@jonhue

Description

@jonhue

Bug Report

πŸ”Ž Search Terms

uncalled function checks, negation

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare function isFoo(): boolean;
declare const isUndefinedFoo: (() => boolean) | undefined;

if (isFoo) {
    // uncalled function checks already work well here
}

if (!isFoo) {
    // uncalled function checks should cover this case too
}

if (!isUndefinedFoo) {
    // this case should not be covered
}

πŸ™ Actual behavior

Uncalled function checks do not work with the ! operator.

πŸ™‚ Expected behavior

Unless a function may be undefined it would be very helpful to check whether it is called when it is used with the ! operator.

I created this issue to separate a part of the implementation of #42835 resulting from issue #35584. This specific issue was inspired by #35584 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions