5 ms·
I saw your tweet about cracking type inference for recursive schemas. It seems like the solution to this problem is pretty straightforward and simple. Was the s
by ssousa666 1y ago
I saw your tweet about cracking type inference for recursive schemas. It seems like the solution to this problem is pretty straightforward and simple. Was the solution really as simple as using a getter, or is there some additional complexity that I am failing to grok?
- mary-ext 1y agothe solution is to avoid TypeScript eagerly validating the object's value type. eager validation breaks cyclic references.
- mary-ext 1y agoZod's source code is a bit unwieldy to explain what's going on I feel, so here's a small validation library I wrote that uses the same principle https://github.com/mary-ext/atcute/blob/596e023bcb490b16d09a8df15424dd75d7ec921d/packages/lexicons/lexicons/lib/validations/index.ts#L1204 https://github.com/mary-ext/atcute/blob/596e023bcb490b16d09a...