facebook / facebook/flow

Union types are not applied on properties

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

Description

I expect properties to inherit union types

```typescript
type Student = {
type: 'student'
}

type Teacher = {
type: 'teacher'
}

const getType = (someone : Student | Teacher) => someone.type;

const type = getType({ type: 'student' });

('student' : typeof type);
// ^ string literal `teacher` [1] is incompatible with string literal `student` [2].
```

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.