facebook / facebook/flow

Type guard not considered for unreachable code

Open
#5,770 2 comments 0 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

```
function typeGuardNotDetectingUnreachableCode(x: string | boolean) {
if (typeof x === "string" && x === false) {
console.log();
}
}

function unreachableCodeDetectedFine1() {
return;
console.log();
}

function unreachableCodeDetectedFine2() {
throw new Error();
console.log();
}
```

It would be good if the first scenario was highlighted as unreachable code, like the other 2 scenarios are. TypeScript currently detects this scenario.

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.