flow-runtime icon indicating copy to clipboard operation
flow-runtime copied to clipboard

Type spread over intersection types doesn't work

Open EXio4 opened this issue 7 years ago • 0 comments

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


Which package versions are you using?

Reproducible on live demo https://codemix.github.io/flow-runtime/#/try

EXio4 avatar Apr 14 '18 18:04 EXio4