facebook / facebook/flow

Calling function with bound arguments

Offen
#4,602 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
error messages
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

[Example](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgBGcArgHYAmYAvGABRkkC2heATgJQ0B8YAbnACWFdAGM4ZAM4YwUOHABcxclVp0AhgrCMW7LtV7ipcGHgB08AOYaOAblRHpRdWyWlKNWfLOFBlOhgAFoKSADRgAMx26IQudHZAA)

```
type bound = (number) => void

const foo:bound = (a: number) => console.log(a);
const bar:bound = foo.bind(this, 3);

bar();

8: bar();
^ undefined (too few arguments, expected default/rest parameters). This type is incompatible with
3: type bound = (number) => void
^ number
```

Is this a bug, or am I doing something wrong? What's the best practice to handle this kind of situation?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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