facebook / facebook/flow

Incorrect props Infer error when used Intersection types as template parameter in React.ComponentType

Open
#7,946 3 comments 0 reactions 0 assignees View on GitHub
bug needs triage react Typing: unions/intersections
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Flow version: v.0.103.0 or v.0.102.0
[Try flow link](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBLAtgBzgJwBdkwBDAZzACUBTUgY2KnzizAHJ87H2BudGgA88RMIQCeOGmCgZ85YgF4wAb1RgwAaxriAjAC4wC-BgB2AcwA0qAL79UQkcQlSjNenFMATMMrUbtcQAmQ2MzK1t7RwJnSWkAIzhCAAtfGTkFMAAyNw9vflAwVABIGgA3GnxxFPCwDEo4TTAEDBS4AFdiM0JK8ndCDE8AOgdhGLE4sESUtLViwIMwi2t5nRCliLtUFAEx0RdpD1xPGlMlam5CIYBhVjxTU8IAFTiAHmnUnJUk5MqAaR0hlIpnENgAfPYoO1TIxBqYwOYaIRbscHmcABQASkMR3uj1U6jAXEI7Xw8JwLBwlEUYLAry8GDKYJUFLgVKGP3+Ohsr2ADKZ-BsqDymRRODSiORdxOGMxUT2xC8NCgpHaMGIWN8YPRrzFWh0ukUACJdEb9cFjUEzZz8ADxMbTcAwXKgA)
## Actual behavior
```javascript
/* @flow */

import * as React from 'react';

export type first = {
key1: string,
};

export type second = {
key2: string,
};

export type both = first & second;
/*
everything is ok without intersection.
export type both = {
key1:string,
key2:string,
};
*/

export type component = React.ComponentType;

function getComponent(): component {
return props =>

{props.otherKey}/* error here when both is intersection type*/
;
}
const Comp = getComponent();

export default () =>();
```
```
25: return props =>

{props.otherKey}
;
^ Cannot get `props.otherKey` because property `otherKey` is missing in props [1].
References:
22: export type component = React.ComponentType;
^ [1]
```
## Expected behavior
No error when intersection type used.

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.