Skip to content

The message This condition will always return true since the function is always defined is not shown #37149

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
a-tarasyuk opened this issue Mar 2, 2020 · 5 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@a-tarasyuk
Copy link
Contributor

a-tarasyuk commented Mar 2, 2020

TypeScript Version: 3.8.3

Code

const foo = {
    test() {
        return true;
    }
}

if (foo.test) {
    console.log(true);
}

Expected behavior:
The message This condition will always return true since the function is always defined should be shown for the code if (foo.test)

Actual behavior:
no message

Playground Link: Example

It seems that happens when childSymbol.id and testedFunctionSymbol.id equal to undefined.

if (childSymbol && childSymbol.id === testedFunctionSymbol.id) 
@j-oliveras
Copy link
Contributor

Using the playground link, after any change (for example add a space at start) the error appears.

@j-oliveras
Copy link
Contributor

Probably you already knows, but its a duplicate of #33792.

@sandersn
Copy link
Member

Yep, thanks @j-oliveras!

@a-tarasyuk
Copy link
Contributor Author

@sandersn I think it is similar to this issue #35557, however, it is not related to QF.

@sandersn
Copy link
Member

Maybe, but this issue is fixed in master, whereas #35557 is not. I assumed incorrectly that it was a result of #33792, but I guess not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants