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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mjbvz opened this issue Oct 3, 2019 · 0 comments · Fixed by #37152
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 3, 2019

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

@RyanCavanaugh RyanCavanaugh added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Oct 3, 2019
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.0 milestone May 12, 2020
@DanielRosenwasser DanielRosenwasser added Fixed A PR has been merged for this issue Committed The team has roadmapped this issue and removed Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
3 participants