Skip to content

Merging two variables with same indexer does not work #8178

@frontendphil

Description

@frontendphil

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions