-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeBox-Codegen #17
TypeBox-Codegen #17
Conversation
@xddq Heya, made a few updates to the code generation this evening. I wouldn't expect this to break anything on your side, but have added a couple of code generation options to get the TB model mapping over to ArkType (it's quite a interesting library) If you can just give these updates a quick review, can merge em into Cheers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heya!
mhh, arktype looks interesting! The ergonomics look somewhat weird on first sight.
I quickly skimmed over it, nothing to suspicious from my side. Will try to include in ts2typebox in the next couple of days after the merge
@xddq Yeah, it's quite an interesting library with a few very interesting features (specifically these scopes for handling mutual recursive inference). Have the workbench setup for it currently to test it out. https://sinclairzx81.github.io/typebox-workbench/ Happy to let this PR sit for a few days (may add a few additional updates yet), so no hurry on things (though I may need a reminder to merge at some point :D) Cheers mate! |
@xddq Hi, just pushed a couple more commits to this PR. Have included Yup, and also updated to TB 0.30.0 (which is major revision) Tests are still passing here so will likely merge this one through (finally :D) once you've had a look. You may want to check Full rundown of new and breaking changes can be found https://github.com/sinclairzx81/typebox/blob/modifiers/changelog/0.30.0.md. Cheers mate! |
Wow, you are doing insane work here!! Btw. I can't wait to see how people will react to this package once it is ready to be published. |
@xddq Heya, made a few more updates to TypeScriptToTypeBox (partially supporting mapped types (at least at runtime)), and did a bit more work to get this project into a publishable state. Can preview the current state of the generators over at the typebox-transform website (which got a rename). If you spot something broken with the types, there's the best place to repro. Tests are all still passing, will merge this one through (finally)! |
@sinclairzx81 hey! Sorry to bother, but did not want to create a separate issue for this one. Just to make sure, ts2typebox is finally obsolete, isn't it? Will then just archive it and make it link to this repo instead. |
@xddq Hi! Hey, I don't think There's still work to do on this project, have recently been eying up ProtoBuf IDL and GQL as next transform targets (and maybe a runtypes and myzod transforms), so could use some help getting those in order (also I'm not much of GQL user so could really use some insights getting an idea on what might be useful to generate for GQL users) As for |
@sinclairzx81 Hey! Alright, will keep it around then! Damn, ts2everything is an awesome name. You should create/own that package! : ] I assume you mean GraphQL? I think GQL is rather this. For GraphQL I could certainly help! As a first step I guess simple schema creation could be useful. As another one I guess custom scalars should be a good fit since the "basic" type system of GraphQL is somewhat limited (but can be extended via custom scalars). Something cool/interesting at the later stages could be creating the resolvers. But I guess Typebox has no way to model functions types.. correct? I will go ahead and do some research if people would even like Typescript to GraphQL. Will create an issue or discussion in this repo in the next couple of weeks on this. Edit: Giving it a quick thought, I am not sure if creating GraphQL will be useful. It e.g. has no "undefined", requires types for functions to be complete, needs a ton of custom scalars (and their typescript implementation) to support the json schema keywords. |
@sinclairzx81 quick update, hope you are doing good!
|
@xddq Hey, thanks for the update! :)
Yeah, still pondering how to approach GraphQL, ProtoBuf and SQL (DDL) (which is another thing I'm looking into). The problem mapping over to these targets is that the type systems for them are misaligned to the capabilities of TypeScript (so creating mappings for them usually requires losing something in the process). I do still think there's some merit to mapping them though (even if the developer needs to constrain types to those expressible in these targets) ... But it's tricky one as usually it's a case of being up against developer expectations while simultaneously being constrained by the thing being mapped into. That said, I did make a start on ProtoBuf (gRPC) IDL https://github.com/sinclairzx81/typebox-workbench/blob/main/src/codegen/model/model-to-grpc.ts which is 90% Thanks again for the update. Currently letting the codegen package settle for a while before doing more work on it (and to give a few of the target libraries some time to update), Also it's great to hear Cheers! |
This PR implements compiler support various reference models used in TB code generation. The options are
inline
,ordered
andcyclic
with the latter option used to express schematics representing mutual recursive types (specifically for ArkType code generation). The reference model can be configured by way of option on TypeScriptToTypeBox. The default isinline
Inline
Ordered
Cyclic
PR also includes a new ArkType transform (very provisional and waiting on some features upstream)