Type spread over intersection types doesn't work
- Dominant language
- JavaScript
- Stars
- 797
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
This is a:
- [x] Bug Report
- [ ] Feature Request
- [ ] Question
- [ ] Other
Which concerns:
- [x] flow-runtime
- [x] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website
---
### What is the current behaviour?
A type spread over an intersection creates invalid code
```
import t from 'flow-runtime';
type C1 = { type: 'C1' } & { test1: string }
type Err = { id: number, ...C1 }
const v : Err = { id: 10, type: 'C1', test1: 'whatever' }
console.log(t.validate(Err, v).hasErrors())
```
---
### What is the expected behaviour?
To be consistent with Flow's semantics
[Try Flow example](https://flow.org/try/#0C4TwDgpgBAwgjFAvFA3lUkBcUDk8dQC+UAZKuhAM7BzbUBOAlgHYDmRAUBxtAKL30k5RgBNszAK4BbAEYR6AGigA6VfE5QOAYwD2zalABuUbP0HI0o7HAAMSntjxwc9qjUcB3ABYBDYBEN5AkIgA)
---
### Which package versions are you using?
Reproducible on live demo https://codemix.github.io/flow-runtime/#/try
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.