How writing TypeScript type in ReScript

I want a type in ReScript, but the compiler keeps reporting an error, using Typescript I can write like this

type Node = {
    parentNode: Node | null,
    childrenNode: Node[],
}

in ReScript

type rec node = {
  "parentNode": node | None,
  "childrenNode": array<node>
} 

there are error, Is there any way? Thanks.

type rec node =
    | ParentNode(option<node>)
    | ChildrenNode(array<node>)
type rec node = {
  parentNode: Js.Null.t<node>,
  childrenNode: array<node>
}

2 Likes