Skip to content

Exact fails when doing es6 object spread #2405

@MarcoPolo

Description

@MarcoPolo

This fails:

// @flow

type A = {|
  foo: number
|}

const foo: A = {foo: 3}
const bar: A = {...foo}

With error:

demo.js:8
  8: const bar: A = {...foo}
                    ^^^^^^^^ object literal. Inexact type is incompatible with exact type
  8: const bar: A = {...foo}
                ^ exact type: object type

This pattern is pretty common in redux style reducers where you return the old state merged with new values (e.g.{...foo, foo: 4})

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions