facebook / facebook/flow

Why does a guard with a optional param doesn't work if reassigned?

Open
#5,755 11 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Why does this simple example fails?

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVUCuA7AxgFwEs5sx8BTAZ3wAoALcmeAfgC4xqAnQ7AcwEowAb1RgwuEtTC9MAQ04ATMAF4wDJnFFhCUGjPkLBIsWM7l8mTqQAGvM+Z68wAEiHr4AX2taPqD0A

```javascript
/* @flow */

function test(hello?: string) {
const guard = hello
if(guard) {
return `greeting ${hello}`
}
}
```

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.