Setting up generics for a constructable schema in TypeScript can be a bit tricky, especially when...

How do I set up the generics for a constructable schema? For example, if I have a function that returns a Schema.Struct, manually setting the return type of that fn to Schema.Schema<A, I> (with the relevant shape for my use-case) doesn't return a shape including the .make fn or fields property.

I can have my method accept i.e. Fields extends Schema.Struct.Fields, which I can then return as a Schema.Struct<Fields> but letting the consumer pass an object of fields doesn't always line up with what I'm trying to do. Is there another approach?
Was this page helpful?