facebook / facebook/flow

Type refinement breaks on simple, exact object types

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

Descrizione

I just discovered exact-typed objects in the docs, but refinement doesn't seem to be working correctly:

```js
type S = {| |};

type L = {|
k: string
|};

declare var x: S | L;

if (x.k === undefined) {
// S|L ↦ S
(x: L); //ng
(x: S);
(x: S | L);
} else {
// S|L ↦ L
(x: L); //Flow mistakenly calls this an error
(x: S); //ng
(x: S | L);
}

if (x.k !== undefined) {
// S|L ↦ L
(x: L); //Flow mistakenly calls this an error
(x: S); //ng
(x: S | L);
} else {
// S|L ↦ S
(x: L); //ng
(x: S);
(x: S | L);
}
```

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.