4 ms·
No, it's more like a type reflection system, at least as I understand it. You can use it to parse types, but you can also do a lot more than that.
by MrJohz 2y ago
No, it's more like a type reflection system, at least as I understand it. You can use it to parse types, but you can also do a lot more than that.
- vosper 2y agoCould you give an example or two of “more than that”?
- mintplant 2y agoYeah, you can walk the AST of your types at runtime and do arbitrary things with it. For example, we're using ArkTypes as our single source of truth for our data and deriving database schemas from them. This becomes very nice because ArkType's data model is close to an enriched version of TypeScript's own data model. So it's like having your TypeScript types introspectable and transformable at runtime.
- vosper 2y agoThat's neat, thanks!
- retropragma 2y agoTypeBox is similar by virtue of its goal of its runtime types matching JSON Schema's data model without need for conversion.
- epolanski 2y agoYou can do whatever you want with the AST in effect schema too, it's a parser with a decoder/encoder architecture: https://effect.website/docs/schema/transformations/ https://effect.website/docs/schema/transformations/