facebook / facebook/flow

Support overloading method signatures in object types

Đang mở
#1,556 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Typing: object model
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ả

I want to do something like this in Flow

```
type DifferentOutputs = {
doThing(name: 'number'): number;
doThing(name: 'Promise'): Promise;
}

function f(d: DifferentOutputs) {
var n: number = d.doThing('number');
}
```

This code is now rejected by Flow.

This logic is actually possible in flow - but only in the declaration files. See : https://github.com/facebook/flow/blob/master/lib/dom.js#L292-L310

I am not sure how to write this logic into my own types, and why it's possible only in external declarations.

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.