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

readonly object spread fails: property bar is read-only in object type [1] but writable in object literal [2]. #7242

Closed
villesau opened this issue Dec 7, 2018 · 1 comment

Comments

@villesau
Copy link
Contributor

villesau commented Dec 7, 2018

Try flow

Following code:

// @flow

export type Ob = {|
  +foo: {| +bar: string |}
|};

export const updateFieldConfig = (update: Ob) =>
	({ foo: { bar: 'valid' }, ...update })

results following error:

4:   +foo: {| +bar: string |}           ^ property `bar` is read-only in object type [1] but writable in object literal [2].
References:
4:   +foo: {| +bar: string |}           ^ [1]
8: 	({ foo: { bar: 'valid' }, ...update })
            ^ [2]

As seen from the snippet, there is no writing happening. The nested object is what's failing. The error location is also very awkward: It's in the type, not in the usage which makes suppressing very inconvenient.

There has been similar bug that's been already fixed in 0.83.0 version, but most likely very related and would lead to proper fix in this case too: #6089

@villesau villesau changed the title $Shape & spread fails: property bar is read-only in object type [1] but writable in object literal [2]. readonly object spread fails: property bar is read-only in object type [1] but writable in object literal [2]. Dec 7, 2018
@goodmind goodmind added this to the New Object Spread semantics milestone Jul 17, 2019
@nmote
Copy link
Contributor

nmote commented Oct 25, 2019

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

Successfully merging a pull request may close this issue.

3 participants