facebook / facebook/flow

instanceof (and probably other) checks don't refine with direct boolean comparison

Open
#4,192 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

`instanceof` always returns a boolean, depending on whether it's something is an instance of something or not.

works:

```js
class A {cool: () => {}}
class B {}
const a = new A
const what: A | B = a;
if (what instanceof A) {
what.cool();
}
```

doesn't:

```js
class A {cool: () => {}}
class B {}
const a = new A
const what: A | B = a;
if ((what instanceof A) === true) {
what.cool();
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.