Intersection of intersections doesn't cast to itself after spreading
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Flow version: 0.155
## Expected behavior
`{...foo}` contains all the same properties as `foo` does, so it should cast to `FooBarBaz`
## Actual behavior
```
13: ({...foo}: FooBarBaz)
^ Cannot cast object literal to `FooBarBaz` because property `baz` is missing in object literal [1] but exists in `Baz` [2].
References:
13: ({...foo}: FooBarBaz)
^ [1]
9: type FooBarBaz = FooBar & Baz
```
* Link to Try-Flow or Github repo:
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgBiccYAvGAN5QkBcYAzhgE4CWAdgOYA0YAdAIC+mXAQBCAQ2bkqAIyn0mbLrwF9h2fGEkAvGZXk7FLDj35D0mgsTiTpFG2ABk2qZdFESd3TJt3nrjroACZ4AMYwUgQAblJgNHD0flK66AAUlGoJgkleKRI6AJSoYKVgQA
```js
/* @flow */
type Foo = {foo: string, ...}
type Bar = {bar: string, ...}
type Baz = {baz: string, ...}
type FooBar = Foo & Bar
type FooBarBaz = FooBar & Baz
declare var foo: FooBarBaz
({...foo}: FooBarBaz)
```
It works OK if I use a flat intersection `type FooBarBaz = Foo & Bar & Baz`
Contributor guide
Assessment
This issue has not been assessed yet.