facebook / facebook/flow

Flow doesn't propagate refinement information through variable

Open
#7,629 1 comment 3 reactions 0 assignees View on GitHub
feature request
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Flow version: 0.96.0

## Expected behavior
Null check assigned to variable should prevent flow error: property missing in null

## Actual behavior
Currently null checking is recognised in a statement `if (myVar !== null) { console.log(myVar.prop); }` but fails when assigned to a property:
```
const isVarSet = myVar !== null;
if (isVarSet) { console.log(myVar.prop); }
```

* Link to Try-Flow or Github repo:
[Flow try](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoKBXAdgYwC4CWcWYA5gKZ4Cy5AzrQIYUAUAtnYxWALxhYYwYASjABvVAEgATpQxSS7ek3IBuVAF9U6bPiIkZDfAGE4rAA7FyWPAHUCeABZwMeAKJSpcKWw7KR4iRxiWjwwMxgGLBolLl4Kal8WRU5yITUwMFQMiWBgMCCsELACWmiUgEEANwYCCIAjGHIeMABCFvDIsuV0zOyZPDkSZjaOqMSmgDIJsAADAB5aM0iAPgASUVGuigA6QjxG9TngRZWZtI0tbVxCYjADY1MLLCs8HxjUsUkCos3x5vituQ3ilzhksmBAsFQiVAVUavVGs0RhExu8euDpLJ5GBmDDxnDagwGpNpvMTlg1hsUYDdvYDkdycszmp1EA)

I believe this issue is related too: https://github.com/facebook/flow/issues/7202

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.