React component Interface with 13.0.0-alpha.5

I’ve got an issue, I think related to the new breaking change introduced to make Jsx.component abstract.

Say I’ve got my module Bar.res

type t = {
  id: int,
  name: string,
}

@react.component
let make = (~foo) => foo.name->React.string

and its interface Bar.resi

type t = {
  id: int,
  name: string,
}

@react.component
let make: (~foo: t) => React.element

The new version of the compiler is still happy.

But if my type is a bit more generic, like
Bar.res

type t<'id> = {
  id: 'id,
  name: string,
}

@react.component
let make = (~foo) => foo.name->React.string

Bar.resi

type t<'id> = {
  id: 'id,
  name: string,
}

@react.component
let make: (~foo: t<'id>) => React.element

then the compiler complains:

  The implementation /Projects/test/Bar.res
  does not match the interface ../ocaml/Bar-xyz.cmi:
  Values do not match:
    let make: React.component<props<t<'_weak1>>>
  is not included in
    let make: React.component<props<t<'id>>>
  /Projects/test/Bar.resi:6:1-7:41:
    Expected declaration
  /Projects/test/Bar.res:7:5-8:
    Actual declaration

(I’ve tried to generate an interface file using the vscode plugin but it produces an empty file)

Does someone know what the “new” (post 13.0.0-alpha.5) interface should be?

1 Like

You will also need a matching version of @rescript/react. We still haven’t released a tagged one, will do that soon.

In the meantime, can you try this version:

npm i https://pkg.pr.new/@rescript/react@8b5b33a

which is from the latest master commit move to rescript v13 and use %component_identity · rescript-lang/rescript-react@8b5b33a · GitHub

1 Like

Problem fixed, thanks @cknitt

1 Like

@rescript/react@0.16.0-beta.1 is out now.

4 Likes