facebook / facebook/flow

Overloding methods in class without `declare`

Đang mở
#2,260 11 bình luận 2 reaction 0 người được giao Xem trên GitHub
feature request Typing: unions/intersections
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ả

Using `declare` we can overload methods in classes:

``` js
declare class Foo {
bar(a: number, b: string): number;
bar(b: string): number;
}
```

But is it possible without `declare`?
Here is a not working example just to illustrate what I mean:

``` js
class Foo {
bar(a: number, b: string): number;
bar(b: string): number;
bar(aOrB, maybeB) {
return maybeB !== undefined ? maybeB : aOrB;
}
}
```

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.