[bug] Intersection with a tagged union unable to refine type
- 主要言語
- Rust
- スター
- 22.3k
- フォーク
- 1.9k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
```js
/* @flow */
type A = {a: string}
type B = {b: string, type: 'b'}
type C = {c: string, type: 'c'}
type BorC = B | C
type ABC = A & BorC
const m: ABC = {type: 'b', a: '', b: ''}
if (m.type === 'b') {
m.b // Error!
// Also interesting. If you have this line, then the `const m` line gets
// a flow error. Remove the line, and the error on `const m` goes away.
}
```
[run it on tryflow](https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCCYAvGAN4CGAXGAM4YBOAlgHYDmAvprgQEKkKAI1oMWHADRhs+WgHIhc7jIIBhQeQDGopm3ZSV8zUp74wfOI3VkBAHzCrTBQn2tEwAMnOXHKogLJiLz4nIjcgh1CXS0JwuzD0TThWBjAAW1oXN3JDMAU5KRE8ygKwGjyTYFBUZigwAAo0gDo-Eja8xQBKClQwdKahVG4q5DRUJJSMMFZMi0ZYjVz8qXK5UqK17lqG1hbeUnb87vJe6YGhoA)
However, a union of intersections works fine
```js
type A = {a: string}
type B = {b: string, type: 'b'}
type C = {c: string, type: 'c'}
type AB = A & B
type AC = A & C
type ABorAC = AB | AC
const n: ABorAC = {type: 'b', a: '', b: ''}
if (n.type === 'b') {
n.b // no error
}
```
コントリビューションガイド
評価
この issue はまだ評価されていません。