Skip to content
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

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

Closed
yseymour opened this issue Aug 23, 2020 · 1 comment · Fixed by #40260
Closed

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

yseymour opened this issue Aug 23, 2020 · 1 comment · Fixed by #40260
Labels
Breaking Change Would introduce errors in existing code Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript

Comments

@yseymour
Copy link

yseymour commented Aug 23, 2020

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.

@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Aug 25, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 25, 2020
@RyanCavanaugh
Copy link
Member

This would probably go well as a PR; see #36402 as a reference point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
3 participants