Skip to content

Flow doesn't propagate refinement information through variable #7629

@patrikniebur

Description

@patrikniebur

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

I believe this issue is related too: #7202

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions