Flow: Intersection between $Shape and regular object generates false errors

Created on 26 Feb 2018  路  2Comments  路  Source: facebook/flow

TRY

// @flow

type Base = {
  s: string,
  n: number,
}

type T = {
  x: number
} & $Shape<Base>

const t: T = {
  s: 'dfg',
  x: 133,
}

In case of usage intersection between regular object type and $Shape object, flow says x is missing in object literal, but obviously x is present.

Possible related issue #5702

destructors

Most helpful comment

I can't speak to the error, but you could spread $Shape<Base> into T: Try Flow.

All 2 comments

I can't speak to the error, but you could spread $Shape<Base> into T: Try Flow.

I wish Flow would automatically consider all object intersections an error if any of the intersected types are mutable, because it's too error prone

Was this page helpful?
0 / 5 - 0 ratings