Skip to content

Make Jsx.component abstract #8072

Description

@cknitt

I mentioned this quite a few times already, I think we should absolutely make Jsx.component abstract.

Reasons:

First, the existing type definition as

type component<'props> = 'props => Jsx.element

is simply wrong. There are a lot of React components that do not have this shape, like class components, fragments, memoized components, etc., etc.

Second, the existing definition leads to weird errors / weird workarounds when writing bindings. Even though Jsx.component<'props> is defined as 'props => Jsx.element, the two are not equivalent when writing bindings.

You need to use Jsx.component<'props> (or @jsx.component, but that's not always what you want) and not props => Jsx.element. Otherwise you end up with things like <prim => SomeLib.Head(prim)> instead of <Head> in the JS output (latest instance of this problem in #8047).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions