-
Notifications
You must be signed in to change notification settings - Fork 2
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
Enhancement: option to generate static type based on the runtype #28
Comments
Sounds totally reasonable to me to support this. |
Should be a fairly small change. Might need to propagate some options to the various writers, but that should be straight-forward. |
I tried this out. Almost no code, so that's good 👍 See PR. One issue here, what to do about naming? have the runtype name be lowercase and the type name be uppercase? Should it be configurable? We could support a callback for creating the names I suppose, for anyone that wants something else than the default. Should the default be to create types or not? Thoughts @haradzienski @cobraz ? |
@haradzienski I would love to help out with that! It has been a wish for quite some time to build a tool that can do just that. I've currently only written some documentation/planning: https://gist.github.com/cobraz/a0031905833bc58d233451fe537f3019 I'm pretty sure there are lots of people who wants that to help :) |
I like the lower/upper-case version!
Probably a good thing!
We should probably create it by default! |
Updated |
@cobraz unfortunately the code for it is not in a public repo right now. I'll see what I can do to open-source it though. @runeh I've checked out the PR, looks great - thank you so much for implementing that! I left a small comment regarding an edge case in default behavior, but otherwise - can't wait to try it out. |
🎉 This issue has been resolved in version 2.0.0-alpha.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi there! ✋
First of all, thank you for such a wonderful library - I've played with version
2.0.0-alpha-3
a bit, and it's awesome!I am using the lib to generate runtypes based on an OpenAPI v2 (Swagger) spec, and I think it would be nice if there was an option to generate a static type (
type Something = rt.Static<typeof something>;
) based on the root type. I think it could work similar to howexport
flag currently works. I checked out the code, and looks like it could be as easy as adding one moreconditionalWrite
to this function: https://github.com/cobraz/generate-runtypes/blob/develop/src/main.ts#L84-L89.I could make a PR if that's something you'd be willing to pull in.
Looking forward to hearing from you, and thanks again!
The text was updated successfully, but these errors were encountered: