Skip to content

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

Closed
@a-tarasyuk

Description

@a-tarasyuk

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) 

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