-
Notifications
You must be signed in to change notification settings - Fork 336
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
TypeScript type generation directly from Rust types #2093
Comments
Just adding this here to not forget: apparently some people are not using the Technically we have two options:
I think the second option would probably be nicer for our consumers since it doesn't break anything for them, but it would increase the macro complexity a bit (but I don't think to a big enough degree to really matter) |
I'm not certain that this is a good assumption. |
@kakucodes that's actually a good point. Especially after looking at things shown off at AwesomWasm that leveraged JSON Schemas. In internal discussions we were talking about different languages parsing TypeScript to generate types from that. But not sure how viable that is in practice. Thoughts? @webmaster128 @chipshort |
After speaking to both Dan and Serdar (who build ts-codegen/go-codegen) I think we should additionally dump an internal machine-readable intermediate represenation that other tools can laverage. So the generation looks like Rust source code -------> JSON dump -------> TypeScript types The advantage of this JSON dump over JSON Schema is that it does not loose information and can be tailored to our needs. |
I would plan for a long lasting transition period where JSON schema remains untouched as long as the users consider it useful. A different type exporter can then be used in addition to that (e.g. by a second function that runs as part of |
In #451 we hit the JSON Schema limitation that an enum must have at least one element. This makes it improssible to describe a type that cannot be instantiated. For the new schemas, could we have a representation of that? We have |
At the moment we generate the TypeScript types by outputting JSON Schema files and then converting them into TypeScript types.
This not only loses some type information but it also complicates the setup.
Since TypeScript is pretty much the only language that clients are written in, we decided through internal discussion that phasing out JSON Schemas in favour of generating TypeScript types is a worthwhile endeavour.
This drops our dependence on the
schemars
crate in favour of using thets-rs
crate to generate these types.The text was updated successfully, but these errors were encountered: