facebook / facebook/flow

Recursive generics

Đang mở
#4,955 0 bình luận 3 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Rust
Star
22.3k
Fork
1.9k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Not sure if it's a bug or a feature request, since neither way of defining a recursive generic type is in the documentation, afaik.

[A generic's qualification cannot reference itself:
](https://flow.org/try/#0GYVwdgxgLglg9mABMOcA8AVAXIg3gIwEMAnAfhwwF8A+ACgEpdKg
)
```
1: function foo(){}
^ identifier `T`. Could not resolve name
```

[But a type definition can:
](https://flow.org/try/#0C4TwDgpgBAcg9gEwgHgCoD4oF4oG8BQUUARgIYBOAXLIihvgL74BmArgHYDGwAlnO1GZw4yAOroAFO1rV4SMegCUuBkA)
```flow
type Node = {
bar: Node
}
function foo(node: Node){}
```
Judging by the fact the latter is implemented, it shouldn't be hard to add.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.