Effect CommunityEC
Effect Community3y ago
14 replies
spaethnl

Error in Recursive Schema Creation

I'm trying to make a recursive schema but I'm getting an error like this:
type 
'Schema<
   { readonly id: string; readonly children?: readonly Node[]; }, 
   { readonly id: string; readonly children?: readonly Node[]; }>' 
is not assignable to type 'Schema<Node, Node>'.


Anyone know why that might be? They seem compatible to me.
const _Node = S.struct({ id: S.string })
interface Node extends S.To<typeof _Node> { children?: Node[] }
const Node: S.Schema<Node> = S.lazy(
  () => S.extend(S.struct({ children: S.optional(S.array(Node)) }))(_Node)
)
Was this page helpful?