facebook / facebook/flow

intersection types behaving unexpectedly when used inside types vs classes

Open
#2,547 5 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

consider [this example](https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCCYAvGAN5hRxwBcYAzhgE4CWAdgOZgC+A3JlwEAQqQpgARgENm9Jmy68Bg-GAAqeALY4YUjHgA8awgBp1wgHxjyqMGAAe9ABRT6xsADJzASlJWAbnCsACYmtmBYzq7qhL4kAUGhqDzoAMa6DAxgAEp47MF4zIVGpuZWNnb62rr6blo6eobGZmqWAnbhqXDs8gCuqRhwzE5VDbXq9TVNpa0WvhVgAJAYABasDAB0o1Ni243tvMlp3UxgGHXVjQalltbhjmBOlNRwZtLMvHHlPGF2kY-PGifPwUH7JZTsPBIXL5QqFEbePhAA) vs [this one](https://flowtype.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCCYAvGAN5hRxwBcYAzhgE4CWAdgOZgC+A3JlwEAQqQpgARgENm9Jmy68BqAMYwpDBmAAqeALY51GPAB5tARgA0OgEwA+CqjBgAHvQAUU+hbAAyWwCUpA4AbnCsACYCzlgeXjrmQSSh4VFOYOkqcOzyAK4qGHDM7pQu1li8QeTpzhgAFqwMAHQuYi7RzmD1jU0VZFgdPKhDquqaYABKeOwReMxzZla2DtW1+oZSxt7rRqYW1tr2HZnZeQVF7sYGu9vXm3tLh3ZV6QCQ3c1XG8ZiX7uDw3QWRyGC6t2+pkI1mEDjI7DwSF0d2MJXSbjAJSoNGs0mYlWCFB4lnSsQxlGocHxyUJxJ4AWU8KQUxmczml3pQA)

The only thing changing between the two is that in the first case I use `type` and in the second I use `class`. For some reason the intersection inside the type throws an error. The same intersection inside a class (or even an interface) doesn't throw. I believe this is a bug

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.