facebook / facebook/flow

Cannot type check code with a union type involving tuples.

Open
#5,281 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I have the [following](https://flow.org/try/#0C4TwDgpgBAogZnCBjYUC8UDk9Es1KAKFEigCUAeAZQD50oAKAZ2AENgIAuKKgSnToMqUAD5QA2lQA0sBMmABdXoQAmyADasATtDgBXAHYoAlgHsDUAOYRgAWVNr11Gg3WnTYbsLGSZOeUpeANzE4NBUbBz0LFrGBpaESOYsUFrclBHsEHT0zJEQ-Gh0LFnoaGiYTKYAthCZHPgA-FAlUdzirRAy2HJ4ConJqJ0A6sbAABb+KPRaDJis9RCYykkGKdUOEOpe+fTWdpvqeVmjE1PAvEA) problem with some code involving redux-loop. Does anybody have an idea why the last line does not typecheck?

```
type Effect = 'Effect'
type R = (state: S) => (S | [S, Effect])
declare function getModel(loop: S | [S, Effect]): S;
type State = {state: string}
const r: R = (state) => state ==='someState' ? state : [state, 'Effect']
const stateWithEffect = r({state: 'aState'})
const model: State = getModel(stateWithEffect)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.