Typing the return type of Schema constructor

Hi all! I'm just getting into effect and I figured a good way to do it would be to transform some of my existing zod code. And I've ran into something I didn't quite know how to do. I have a simple interface like:

interface Edge<Node, Cursor> {
  node: Node,
  cursor: Cursor,
}


And I want to write a type constructor for it where one can pass their own schemas for node and cursor. This is pretty simple, but I'm having issues typing the return type to ensure it conforms to the existing Edge interface.

export function EdgeSchema<Node extends Schema.Schema.Any, Cursor extends Schema.Schema.Any>(
  node: Node,
  cursor: Cursor,
) {
  return Schema.Struct({
    cursor,
    node,
  });
}


I've tried adding a satisfies Schema.Schema<Edge<Schema.Schema.Type<Node>, Schema.Schema.Type<Cursor>>> to the Struct call, but that doesn't work. I assume there is something easy I'm missing here haha
Was this page helpful?