facebook / facebook/flow

Union type of exact object types doesn't add refinement based on property only in one of the choices

Offen
#4,772 6 Kommentare 12 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Typing: unions/intersections
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

If this is a bug, please try reproducing using https://flow.org/try/.

Reproducible: https://flow.org/try/#0PTAEAEDMBsHsHcBQBLAtgB1gJwC6gEoCmAhgMZ6RayqgDkWJ5tA3IqbAHYDOepAHqAC8oABQA6CcQ4BPAFxTpASiEA+OsVqJEOaekKgAClXRchoAN4AfRKFAdiqQrNA8syDgHMANDdCloxFxcAHIOTqAA-K7u3oiWAL6glhbWtvaOXM4AglhYxNIAPNGeKj62-oEhYc5ROG6ePgmsbJw8oB6EOADCAUGhGWYi6YSZoDl5hcUeKorZuflFdTFqgmrmvgw4AK5YHHZhXGKoxOhDYar7joqs8c3s3HgAkveD6MajRrAmyquivkXoKR+XpVRyCcz8ERvL6HCp9MJedqdHqVfojKHvMTDSKgADa0JMWLCAF1QM4CYdhlxFIp4sAVIhrlogA

// @flow
import React from 'react';
const cx = (...any:any) => 'a'

type Props = {|
name: string,
className: ?string,
|} | {|
names: Array,
className: ?string,
|};

const getClassNames = (names: Array): Array => {
return names.map(name => name);
};

const Icon = (props: Props) => (

);

Error:

```

18:
^ property `names`. Property not found in
18:
^ object type

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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