Skip to content

Incorrect "did you mean to call" error issued for invoked class property #38161

Closed
@RyanCavanaugh

Description

@RyanCavanaugh

TypeScript Version: nightly

Search Terms: "did you mean to call"

Code

declare const variable: () => void;
class Foo {
  method!: (() => void);

  f() {
    // Error (incorrect)
    if (this.method) {
      this.method();
    }

    // OK (correct)
    if (variable) {
      variable();
    }
  }

}

Expected behavior: No error

Actual behavior: Error: This condition will always return true; did you mean to call it instead?

Playground Link: Linky

Related Issues: Feature introduced at PR #37152

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions