facebook / facebook/flow

Unreachable code not well detected

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

Description

Flow version: 0.44.1
```
function foo(): string {
if (true) {
return ''
}
}

function bar(): string {
while (true) {
return ''
}
}
```
Flow complained:
```
1: function foo(): string {
^ string. This type is incompatible with an implicitly-returned undefined.
7: function bar(): string {
^ string. This type is incompatible with an implicitly-returned undefined.
```
while I expected it would pass since both implicitly-returned undefineds are unreachable.

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.