-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Similar to #8178, but with an additional property. Spreading identical values with properties and indexers creates errors.
export type Trie<T> = {
[string]: Trie<T>,
_?: T,
};
const x: Trie<number> = { };
const y: Trie<number> = { };
const z: Trie<number> = { ...x, ...y };
Flow version: 0.117.0
Expected behavior
Two values with identical types should always be spreadable
Actual behavior
Error is thrown:
11: const z: Trie<number> = { ...x, ...y };
^ Cannot determine a type for object literal [1]. `Trie` [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 `Trie` [2] first or remove the indexer?
References:
11: const z: Trie<number> = { ...x, ...y };
^ [1]
9: const y: Trie<number> = { };
^ [2]
4: [string]: Trie<T>,
^ [3]
- Link to Try-Flow or Github repo: tryflow