Skip to content

Add quick fix for This condition will always return true since the function is always defined. Did you mean to call it instead #33792

Closed
@mjbvz

Description

@mjbvz

TypeScript Version: 3.7.0-dev.20191003

Search Terms:

  • quick fix
  • code action
  • function
  • missing call

Code

const val = {
    isTrue() { return true; }
}

if (val.isTrue) {
    console.log(true);
}

This code produces the error: This condition will always return true since the function is always defined. Did you mean to call it instead? for the conditional

Expected behavior:
A quick fix to add the missing call is returned. This would change the code to:

const val = {
    isTrue() { return true; }
}

if (val.isTrue()) {
    console.log(true);
}

Actual behavior:
No quick fixes

Metadata

Metadata

Assignees

No one assigned

    Labels

    CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions