Type refinement breaks on simple, exact object types
Open
Typing: refinements
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I just discovered exact-typed objects in the docs, but refinement doesn't seem to be working correctly:
```js
type S = {| |};
type L = {|
k: string
|};
declare var x: S | L;
if (x.k === undefined) {
// S|L ↦ S
(x: L); //ng
(x: S);
(x: S | L);
} else {
// S|L ↦ L
(x: L); //Flow mistakenly calls this an error
(x: S); //ng
(x: S | L);
}
if (x.k !== undefined) {
// S|L ↦ L
(x: L); //Flow mistakenly calls this an error
(x: S); //ng
(x: S | L);
} else {
// S|L ↦ S
(x: L); //ng
(x: S);
(x: S | L);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.