-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[feat] Generate Typescript Declaration from Structs in Rust #3586
Comments
Great idea! This kind of automation is nice for those lucky enough to struggle with TS in their day-to-day work. |
possibly duplicate of #1514 And tbh I don't know why should we implement this since there is already crates for it out there. https://crates.io/crates/typescript-definitions |
Yeah i think for this specific use-case it makes more sense to promote existing solutions (maybe integrate them in the docs or use them in an example). |
in a sense, yes it is, and my idea is to implement the crates you listed into the build system, so when you run |
Closing as duplicate of #1514. |
Describe the problem
Typically, when you create a struct on the rust side, you need to declare the same struct on the typescript side using a
.d.ts
file or having a dedicated interface file. This normally isn't bad if not a little bit time consuming, though it does open up the floodgates for human error which can slow progress down significantly on larger codebases.Describe the solution you'd like
There is a rust crate that can do this, however, which is simply a
derive
macro in typescript-definitions.my knowledge of rust (and this code base) is very limited however it may be a good idea to have
#[tauri::struct]
macro in the same way we have#[tauri::command]
, which would release typescript definition files should a typescript mode be enabled in the projectstauri.conf.json
.The developer could then simply attach this
#[tauri::struct]
to any struct that are supposed to be accessed by the front end (and while its there, it may be a good idea to make it deriveserde::Serialize
if you can, idk).Alternatives considered
Realistically this should only be a minor annoyance (that being, creating the
.d.ts
files yourself) until the codebases start scaling massively although it would be a nifty little feature, so if you absolute gods consider something like this it probably wouldn't be the highest priority at the moment all things considered.Additional context
Overall this is purely an idea to improve the developer experience and overall, nothing will happen if this doesn't.
The text was updated successfully, but these errors were encountered: