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

Allow field overrides when spreading types (not spreading values) #7253

Closed
nvie opened this issue Dec 11, 2018 · 2 comments
Closed

Allow field overrides when spreading types (not spreading values) #7253

nvie opened this issue Dec 11, 2018 · 2 comments

Comments

@nvie
Copy link
Contributor

nvie commented Dec 11, 2018

Example

type Thing = {|
  id: number,
  name: string,
|};

type Thing$External = {|
  ...Thing,
  id: string,  // Overwrite ID's to be strings, not numbers
|};

function toExternal(thing: Thing): Thing$External {
  return { ...thing, id: thing.id.toString() };
  //     ^ Cannot return object literal because number [1] is incompatible
  //       with string [2] in property `id`.
}

Expected behaviour

This should work.

Try link

@villesau
Copy link
Contributor

Here is a pr that should fix the issue: #7298

@nmote
Copy link
Contributor

nmote commented Oct 25, 2019

This no longer errors 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