Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread operator inconsistency with optional object properties #7304

Closed
Dbuggerx opened this issue Dec 28, 2018 · 2 comments
Closed

Spread operator inconsistency with optional object properties #7304

Dbuggerx opened this issue Dec 28, 2018 · 2 comments

Comments

@Dbuggerx
Copy link

In the following code, I'd expect both functions to throw an error, but the spread version works.
Try it

/* @flow */

function failsAsExpected(x: A): B {
  return {
     a: x.a,
     b: x.b,
     c: x.c
  };
}

function shouldAlsoFailButWorks(x: A): B {
  return {
   	...x
  };
}

type A = {
    +a: boolean,
    +b: number,
    +c?: string
}

type B = {
    a: boolean,
    b: number,
    c: string
}
@villesau
Copy link
Contributor

@Dbuggerx this pull request fixes this issue as well: #7298

@nmote
Copy link
Contributor

nmote commented Oct 25, 2019

This now has the expected behavior on master

@nmote nmote closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants