facebook / facebook/flow

Type hole with compatibility between optional parameters/extra parameters

Aperta
#3,049 4 commenti 2 reazioni 0 assegnatari Vedi su GitHub
bug Typing: soundness
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

```js
//@flow

const x = (a: number = 1): number => a;
const y: () => number = x;
// No Flow error
// Runtime error: Uncaught TypeError: y(...).toFixed is not a function
y('x').toFixed();

const z: (a: string) => number = y;
// No Flow error
// Runtime error: Uncaught TypeError: z(...).toFixed is not a function
z('x').toFixed();
```

I expected Flow to either report that `(number|void) => number` is incompatible with `() => number`, or that `() => number` is incompatible with `(string) => number`. Either would fix this problem, but allowing both in combination is definitely unsound.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.