flow-runtime
flow-runtime copied to clipboard
Type spread over intersection types doesn't work
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
Which package versions are you using?
Reproducible on live demo https://codemix.github.io/flow-runtime/#/try