Intersection of types with optional fields is incorrect
Open
Typing: unions/intersections
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
The `Foo` type should be compatible with the empty object, since `bar` is optional on both sides of the intersection:
```javascript
type Foo = { bar?: true } & { bar?: false }
let x: Foo = {}
```
However, flow errors:
```
3: let x: Foo = {} ^ Cannot assign object literal to `x` because boolean literal `true` [1] is incompatible with boolean literal `false` [2] in property `bar`.
References:
1: type Foo = { bar?: true } & { bar?: false }
^ [1]
1: type Foo = { bar?: true } & { bar?: false }
^ [2]
```
Contributor guide
Assessment
This issue has not been assessed yet.