Skip to content

Export flow type definitions #160

@romandecker

Description

@romandecker

Would it be possible to export all flow type definitions? Here's a use case:

import { Value } from 'react-powerplug';
import { adopt } from 'react-adopt';

const Composed = adopt({
    foo: <Value initial="bar" />,
    baz: <Value initial="qux" />
});

This will make flow complain:

Cannot create Value element because:
 • Either property render is missing in props [1] but exists in object type [2].
 • Or property children is missing in props [1] but exists in object type [3].

 [2] 274│   | {| initial: T, onChange?: ValueChange<T>, render: ValueRender<T> |}
 [3] 275│   | {| initial: T, onChange?: ValueChange<T>, children: ValueRender<T> |}

Which makes sense I guess. This can be fixed by pulling out the render explicitly:

import { Value } from 'react-powerplug';
import { adopt } from 'react-adopt';

const Composed = adopt({
    foo: ({ render }) => <Value initial="bar">{render}</Value>,
    baz: ({ render }) => <Value initial="qux">{render}</Value>,
});

But now, I have to type render (at least with the react/prop-types eslint-rule active).

Sadly, react-powerplug does not currently export the ValueRender type which makes this hard to do... Could you export all flowtypes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions