facebook / facebook/flow

Error using union types in interface

Aperta
#4,084 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
question Typing: interfaces Typing: property variance
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Minimal reproduction:
```js
// @flow
interface Foo {
type: string | string[];
}
function bar(): Foo {
return { type: 'hello' };
}
```
Expected behavior: Flow type-checks without issue.

Actual behavior: Error
```
test.js:3
3: type: string | string[];
^^^^^^^^ array type. This type is incompatible with the expected return type of
6: return { type: 'hello' };
^^^^^^^ string
```
Flow version: 0.47.0

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.