facebook / facebook/flow

Premature incompatibily errors in generic classes definitions

Open
#3,711 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Here is simplified example:

```js
class Task {
static spawn: (task:Task) => Task
spawn ():Task {
return Task.spawn(this)
}
}
```

Here flow reports following error:

```
6: return Task.spawn(this)
^^^^^^^^^^^^^^^^ call of method `spawn`
3: class Task {
^ x. This type is incompatible with
4: static spawn: (task:Task) => Task
^^^^^ empty
```

What I actually expect is for flow to report type error when `task.spawn()` is called on tasks that can fail (`Task`) and report no errors when called on tasks that can not fail (`Task`).

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.