facebook / facebook/flow

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

Open
#4,772 6 comments 12 reactions 0 assignees View on GitHub
Typing: unions/intersections
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

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

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.