Object destructuring breaks disjoint union type.
- Langage dominant
- Rust
- Étoiles
- 22.3k
- Forks
- 1.9k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
As an example:
```js
type Props =
| { type: 'foo', item: { id: number, parentId: number | null } }
| { type: 'bar', item: { id: number, parentId: number } }
function test(props: Props) {
// This works
const yay = props.type === 'foo'
? props.item.id
: `/parents/${props.item.parentId}/items/${props.item.id}`
// This does not
const { type, item } = props
const boo = type === 'foo'
? item.id
: `/parents/${item.parentId}/items/${item.id}`
}
```
I'm running v0.46. Curiously, the try flow REPL [doesn't exhibit an error](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAodAXAngBwKZgAKATnDgM5gC8qYYAPmAN5jb4BcYA5FHHFwBowASwx4AtpxbCAJpwB2AV3EAjPMSE4AhsTzyMASTlglq9QxOKYMMAF87tCyzZ5OXFTsEixk5iOOmahpg2rr6RgrKQXYOdKhQivIAxhjCcPKseOQYABQ4pBScJGTkAJTMjnTAwGAAKgAWwpQIcMQA1uSVYEnp2WBYWljUIQXkAHQu1FRU3Lz8YF10dAD8IyVjohIbMmCci0sABsChehjkwAAkTPnrm+JjJ+EytsB351c3FBs+27YHXV1qnVGpQZHAsvIuBguj15H1nLg8EI7jEZhgQQ9RjDehgwIpiDY0YipjMeHwuAslmAAJCrO7bSlLamcI6PM6XJj0tlGF5vDn02R-VC2IA), I'm only getting it locally.
Any ideas?
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.