Skip to content

Intersection with AbstractComponent leads to misleading errors #8047

Closed
@omninonsense

Description

@omninonsense

Flow version: 0.104

Expected behavior

Don't error when the intersection can be rendered as a React component.

Alternatively, if this is another strange design decision regarding React.AbstractComponent, can we at least error early (as soon as we try to intersect with AbstractComponent) instead of in a random place in the code.

Actual behavior

Flow complains that React.Component is not a React component when it appears in an intersection with AbstractComponent.

This is a kind of dumbed down example: https://flow.org/try/#0PTAEAEDMBsHsHcBQiCWBbADrATgF1AFSgCGAzqAEoCmxAxvpNrGqAOTY32vIigAqACxTlhoAK6kqAE1BVok+AKodQKAHahcSzQE8M6gOalEtaGXIBJNbmVYzuYgCNoVAMLMsaqtYA8ABQA+WQAPGzUpcmo6XAASd0xYL19A0ABvRFBQUlwdFyl4z29cCykALizcbEMAbkQAX2QcjCpQAGUcvILEov8mDFIAGlArbOI1WioggF5KTliAQUds7GiupNxe2H6hkYdxydAAMmHrW1h7Jxc1nrGdAOQpKlNiFUgxcdwURNA0YgBrKibbYnUb7AIACgAlOV2rlpNdkn1BiC9hMArUTIlsqACqAZr8AT5UnUhqwpCgAG6sCGQ5C0LH4RzEfIwjrwjzdXzE0mkDBjal40A+XHAAJAA

However, a real-world example of this can be found in flow-typed's typedefs for styled-components: https://github.com/flow-typed/flow-typed/pull/3517/files#diff-2b77bbf95ac6caa4414db8ad19a62162 (search for should render as the correct element for the whole test that reproduces this, and for noExpectError for the immediate line below it that triggers the error).

More information about it can be found in flow-typed/flow-typed#3517 (comment) (and some subsequent comments).

/cc @goodmind

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions