facebook / facebook/flow

Intersection types don't work as guards in children

Open
#4,691 0 comments 0 reactions 0 assignees View on GitHub
Typing: unions/intersections
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

This works OK:
```
/* @flow */
import * as React from 'react'

type F = {
name: string,
age: number
}

const Component = (props: {data: ?F}) => (

{props.data && props.data.name}

)
```
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAlgWwA5wE4AuyYAhgM5gBKApiQMZFR5yZgDketDbqqBAntmpgAYmAC8YAN6oAkADsSmagC4wZAnnTyA5gBpUYI6R2qw8gK6YARtTyoAvrzpx5GsAGEWuedXlFJAApsZmwyNSkAExICEjUAfhEHAEoJAD4wQLkAHkj0ADc0qRC4MIA6aNiwADJqsBLyypIyxWUHbOA8wtRk1CA

While this doesn't:
```
/* @flow */
import * as React from 'react'

type F = {
name: string
} & {
age: number
}

const Component = (props: {data: ?F}) => (

{props.data && props.data.name}

)
```
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAlgWwA5wE4AuyYAhgM5gBKApiQMZFR5yZgDketDbqqBAntmpgAYmAC8YAN6oAkADsSmagC4wZAnnTyA5qgC+YAGTS5JHarDyArpgBG1PAd5048jWADCLXPOryiSQAKbGZsMjUpABMSAhI1AH4RfQBKCQA+MCC5AB4o9AA3dKlQuHCAOhi44xNSiqqScsVlfRzgfKLUFNQgA

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.