facebook / facebook/flow

Object types intersection within generics within object types

Open
#4,258 2 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

Trying to intersect object types within generics inside object types.

```
type C = {
beers: Array<{
brand: string
}>
}

type D = {
beers: Array<{
size: number
}>
}

type CD = C & D;

var cd: CD = {beers : [{brand: 'Rothhaus', size: 0.5}]}
```

The variable cd does not fit the type CD. Is this the expected behavior?

Althought it works with this example.
```
type beerWithBrand = {
brand: string
}

type beerWithSize = {
size: number
}

type beerStock = {
beers: Array
}

var stock : beerStock = {beers : [{brand: 'Rothhaus', size: 0.5}]}
```

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.