Interface type within interface should be checked for "implements" instead as normal type while "implements" validation
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
In following fail example, `Foo` and `A` seem to be compared as subtype and supertype and cause it fail. But interface `B` is actually being fullfilled that you can totally operate `Bar#b` as an `A`.
Consider the [iterable and iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) case which an object got `[Symbol.iterator]` method that retrurns `iterator` should implements `iterable` , this kind of behavior should be resonable.
```js
interface A {
a: 'a'
}
interface B {
b: A
}
class Foo implements A {
a = 'a';
}
class Bar implements B {
b: Foo;
}
```
Flow version: 0.94.0
## Expected behavior
Interface types within interfaces should be treated and validated as interface implemantation but not as normal type while validating an "implements" check.
## Actual behavior
```
14: b: Foo
^ Cannot implement `B` [1] with `Bar` because `Foo` [2] is incompatible with `A` [3] in property `b`.
References:
13: class Bar implements B {
^ [1]
14: b: Foo
^ [2]
6: b: A
^ [3]
```
* Link to [Try-Flow](https://flow.org/try/#0JYOwLgpgTgZghgYwgAgILIN4ChnLgLmQHI4isBfLLUSWRFAIUx2QCNDUKqEAbOAZ37IAYgHtRyYAFsADjwhSI4Iemy44yALzFSAbi5ZeAoQzhRJs+YuXImatoTGiKQA)
Contributor guide
Assessment
This issue has not been assessed yet.