close
Skip to content

No "did you mean to call" error when invocation is part of a logical expression #40197

@yseymour

Description

@yseymour

TypeScript Version: v4.1.0-dev.20200822

Search Terms: "did you mean to call"

Code

function foo() { return false }
function is_foo_1() { return foo ? 1 : 0 }
function is_foo_2() { return foo && 1 }

Expected behavior:
The same error (2774) on the access of foo in both is_foo_1 and is_foo_2.

Actual behavior:
Only is_foo_1 shows the error. However, from a logical standpoint, I would consider them to be equally incorrect. !foo doesn't give an error either.

Playground Link:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20200822#code/GYVwdgxgLglg9mABMOcAUBKRBvRAnAUyhDyWAEMAbAZwMQF8AoUSWBRGagfRTi4EZMOfERJlUiAPyJ+iAFyIADA2bho8JJx6ouAJiG5CxUsgkAyMzIZA

Related Issues:
I found discussions about the implementation of this error, but nothing specific to logical expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions