Flow: Merging two variables with same indexer does not work

Created on 5 Nov 2019  Â·  8Comments  Â·  Source: facebook/flow

Flow version: 0.111

//@flow
type Indexed = { [string]: number };
const x: Indexed = {foo: 3};
const y: Indexed = {bar: 5}

const z: Indexed = {...x, ...y};

Try here

Expected behavior

I would have expected that the assignment to z works because all indexers are the same so the new variable should also work.

Actual behavior

Cannot determine a type for object literal [1]. `Indexed` [2] cannot be spread because the indexer string [3] may overwrite properties with explicit keys in a way that Flow cannot track. Can you spread `Indexed` [2] first or remove the indexer?
bug

Most helpful comment

There's diffs up for it, but won't make it in until 113

All 8 comments

on my radar. trying to fix + put out in a patch

We also experience this problem in graphql-js, see:
https://github.com/graphql/graphql-js/pull/2251/files#diff-a2222d77ff884acdf97c5f295babf27c

There's diffs up for it, but won't make it in until 113

Just checking: This didn’t get into 113, did it?

No, still waiting for review

On Wed, Dec 4, 2019 at 11:02 AM Simon Lydell notifications@github.com
wrote:

Just checking: This didn’t get into 113, did it?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/flow/issues/8178?email_source=notifications&email_token=ACBH3T2VUBOVRTQF75VGA5TQW7ICFA5CNFSM4JJAJN52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF5QPAA#issuecomment-561710976,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACBH3TZHZAM3UPXVHZG7UQDQW7ICFANCNFSM4JJAJN5Q
.

>

Sent from Gmail Mobile

Any update? Thanks!

The tryflow link works from 0.115 and I saw something in the changelog so I think this should be closed now.

I'm closing this myself since it has been fixed in the meantime.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Macil picture Macil  Â·  47Comments

danvk picture danvk  Â·  73Comments

StoneCypher picture StoneCypher  Â·  253Comments

jamesisaac picture jamesisaac  Â·  44Comments

gabro picture gabro  Â·  57Comments