facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.08k stars 1.86k forks source link

`typeof mixed === 'object' && mixed` should not report sketchy-null-mixed #4524

Open TiddoLangerak opened 7 years ago

TiddoLangerak commented 7 years ago

Consider these 2 snippets:

declare var m : ?mixed;
if (typeof m === 'object' && m) {
  /*snip*/
}

if (typeof m === 'object') {
  if (m) {
  }
}

In the first case flow-lint reports a sketchy-null-mixed error, while in the second case it does not. I think that flow should not report an error in both cases, since the only falsy value with type === 'object' is null.

g3r4n commented 7 years ago

Fixed in flow >= v0.50.0. We can reproduce this issue with v0.49.1.

TiddoLangerak commented 7 years ago

This is still reproducable in flow v0.52

asolove commented 7 years ago

Still reproducible in Flow .53.