Effect CommunityEC
Effect Community•3y ago•
10 replies
Rory

Generating a Schema from an Existing Interface

I may have overlooked this. How do I generate a Schema from an existing interface? This happens a lot when I'm given interfaces from an external library and I want to use them for parsing. Good example is Stripe, where they expect you to YOLO and just hard cast everything 🙄 .
This also comes up frequently with graphql, when I have an anonymous type that's generated as a return value of a query.
const StripeEvent = S.magicInterfaceConversion<Stripe.Event>(); // does this exist?
const event = req.body as Stripe.Event // ugh what Stripe wants you to do
const evt = pipe(req.body, S.parse(StripeEvent)) // what I would rather do
Was this page helpful?