facebook / facebook/flow

Support overloading method signatures in object types

Open
#1,556 5 comments 0 reactions 0 assignees View on GitHub
Typing: object model
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

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.

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.