facebook / facebook/flow

Support overloading method signatures in object types

Offen
#1,556 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Typing: object model
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.