-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Incorrect "did you mean to call" error issued for invoked class property #38161
Comments
@decherneyge that is precisely the intended behavior |
@RyanCavanaugh oh ok. Thanks for the reply! Why is it the intended behavior? |
@decherneyge See discussion in #32802 and linked issues from there |
interface A {
a: () => boolean;
}
class AImpl implements A {
public a(): boolean {
return true;
}
}
it('should fail', function () {
const aImpl = new AImpl();
if (aImpl.a) { // TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
console.log("always true");
}
});
it('why success', function () {
const aImpl = new AImpl();
if (!aImpl.a) { // nothing happens here
console.log('always false');
}
}); just wondering why |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript Version: nightly
Search Terms: "did you mean to call"
Code
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
The text was updated successfully, but these errors were encountered: