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

Changing object property type with Object.assign() #7332

Closed
quarryman opened this issue Jan 9, 2019 · 2 comments
Closed

Changing object property type with Object.assign() #7332

quarryman opened this issue Jan 9, 2019 · 2 comments

Comments

@quarryman
Copy link

quarryman commented Jan 9, 2019

Given I have value of exact type A and want to transform it to exact type B using Object.assign

type Coordinates = {|
  lat: number,
  lon: number,
|}

type RawCoordinates = {|
  lat: number,
  lon: string,
|}

const c1: Coordinates = { lat: 1, lon: 2 }
const c2: RawCoordinates = { lat: 1, lon: 'two' }

const merged: RawCoordinates = Object.assign(c1, c2);

const merged2: RawCoordinates = Object.assign({}, c1, c2);

How to avoid flow error using Object.assign/spread/ any other option of changing property type?

Try Flow

There are similar issues however they address reassigning object property to the value of the same type, while I need reassign to another type

@jamesisaac
Copy link
Contributor

I think this would be solved by #7298

@SamChou19815
Copy link
Contributor

Going forward, we will likely only supporting object spreads well.

@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2023
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