Flow does not catch invalid switch statements
ayroblu opened this issue · 1 comments
ayroblu commented
Posting here, cause this caused a production incident at our company. For the most part we're "fine" with our usage of flow, but this is one of the more serious bugs
Flow version:
0.220.1
Expected behavior
Incorrect switch case statements should throw an error
Actual behavior
Switch case statements are allowed to do anything
- Link to Try-Flow or Github repo: link
Specifically see this part:
Note the usage of "random_access"
gkz commented
Thanks for the report. For now, if using the disjoint object union pattern, stick to using literal types 'foo'
directly rather than using typeof X.Foo
, both when defining the type and when refining it (e.g. in a switch
).